Skip to content

Instantly share code, notes, and snippets.

@strepicor
Last active April 2, 2024 02:19
Show Gist options
  • Save strepicor/95a87770728bc5479ea650b0e217b211 to your computer and use it in GitHub Desktop.
Save strepicor/95a87770728bc5479ea650b0e217b211 to your computer and use it in GitHub Desktop.
Epicor Customization - Retrieve Data from a BAQ
// Add a reference to "Ice.Contracts.Bo.DynamicQuery"
public struct BaqParam
{
public BaqParam(string paramName, string paramType, string paramValue)
{
this.ParamName = paramName;
this.ParamType = paramType;
this.ParamValue = paramValue;
}
public String ParamName;
public String ParamType;
public String ParamValue;
}
public DataTable getDataFromBAQ(String BaqID, ArrayList BaqParams)
{
DataTable tbToReturn = new DataTable();
DynamicQueryAdapter adQuery = new DynamicQueryAdapter(oTrans);
adQuery.BOConnect();
QueryExecutionDataSet ds = new QueryExecutionDataSet();
foreach (BaqParam Param in BaqParams){
ds.ExecutionParameter.AddExecutionParameterRow(Param.ParamName, //Name of the Parameter
Param.ParamValue, // Value of the Parameter
Param.ParamType, //Type of the Parameter
false,
new Guid(),
"A");
}
adQuery.ExecuteByID(BaqID, ds);
tbToReturn = adQuery.QueryResults.Tables[0];
adQuery.Dispose();
return tbToReturn;
}
public void MethodThatRequiresDataFromBAQ()
{
try
{
ArrayList Params = new ArrayList(){
new BaqParam("BAQParameterName", "nvarchar", ((Ice.Core.Session)(PartForm.Session)).UserID.ToString())
};
DataTable dtData = getDataFromBAQ("YourBAQName", Params);
this.cmbNewPartMainClass.DataSource = dtData;
this.cmbNewPartMainClass.ValueMember = "ValueFieldName";
this.cmbNewPartMainClass.DisplayMember = "DisplayFieldName";
string[] fields = new string[] {"DisplayFieldName"};
this.cmbNewPartMainClass.SetColumnFilter(fields);
}
catch (Exception Ex)
{
throw new Exception(Ex.Message);
}
}
@MrDonph0x
Copy link

That's a very good code,
in my case i use List to pass the params to the BAQ.
BTW with this code you can send List Parameters and that multiply the uses of a BAQ in your's develops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment