Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Forked from jlewin/executeEpicorBAQ.cs
Last active August 29, 2015 14:17
Show Gist options
  • Save hasokeric/bc4b2d2086f677e652b7 to your computer and use it in GitHub Desktop.
Save hasokeric/bc4b2d2086f677e652b7 to your computer and use it in GitHub Desktop.
// Execute BAQ with parameter
using (var session = new Epicor.Mfg.Core.Session("user", "secret", "AppServerDC://server:port"))
{
// DynamnicQuery for BAQ
var dynamicQuery = new Epicor.Mfg.BO.DynamicQuery(session.ConnectionPool);
// Build Parameters DS
QueryExecutionDataSet executionDS = new QueryExecutionDataSet();
// Actual parameter row
var paramRow = executionDS.ExecutionParameter.NewRow();
paramRow["ParameterName"] = "StartDate";
paramRow["ParameterValue"] = "6/15/2011";
paramRow["ValueType"] = "date";
paramRow["IsEmpty"] = "False";
paramRow["RowIdent"] = "";
paramRow["RowMod"] = "";
paramRow["DBRowIdent"] = new byte[0];
executionDS.ExecutionParameter.Rows.Add(paramRow);
// Out variable which indicates if more results are available (likely for use with topNRecords)
bool hasMoreRecords;
// Executed named BAQ with parameter
var results = dynamicQuery.ExecuteByIDParametrized("01-NamedBAQ", executionDS, "", 0, out hasMoreRecords);
// Store results
results.WriteXml(@"c:\temp\BAQWithParamResults.xml");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment