Epicor functions and BAQs

I have the code working to run the Db retrieval parts, but I am missing something in the syntax (I think) when I try to run the External BAQ. I am getting the row count to be 0, which I think is because I am not filling in the project ID parameter correctly. Here is my code

using (var svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(context))
{ 
   var BAQName = svc.GetQueryExecutionParametersByID("Cobra_Project_Cost");
   var param = BAQName.ExecutionParameter.Where(r=>r.ParameterID=="ProjectID").FirstOrDefault();
  
  foreach (var PROJ in project)
  {
    vProject = PROJ.ProjectID;
    var CProj = Db.UD19.Where(e=> e.Key1 == vProject.ToString());
    foreach (var CName in CProj)
    {
      Cobra_Project = CName.Character01;
      BAQName.ExecutionParameter.Clear();  
      param.ParameterValue = Cobra_Project;      
      dsCobra = svc.ExecuteByID("Cobra_Project_Cost", BAQName);
      dtCobra = dsCobra.Tables[0];
      //set up the project cost table
      int rcount = dtCobra.Rows.Count;

Have I properly set up the param variable to be the parameter, with the line param.ParameterValue filling in the value?

Hereā€™s my basic boilerplate, including parameters:

var context = Ice.Services.ContextFactory.CreateContext<ErpContext>(); 

using (var svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(context)) 
{ 
    Ice.Tablesets.DynamicQueryTableset dsQuery = svc.GetByID("BAQNAME"); 

    if (dsQuery != null) 
    { 
        Ice.Tablesets.QueryExecutionTableset dsBAQ = svc.GetQueryExecutionParameters(dsQuery); 
        dsBAQ.ExecutionParameter[0].ParameterID = "PARAMETERNAME"; 
        dsBAQ.ExecutionParameter[0].IsEmpty = false; 
        dsBAQ.ExecutionParameter[0].ParameterValue = "PARAMETERASSTRING"; 
        DataSet results = svc.Execute(dsQuery,dsBAQ); 

    } 
}
5 Likes

Thanks so much! I was able to get this all working, including updating data with Db.

1 Like

Still not too late, thank you for the brilliant tip, it helped !

1 Like

Ā”ResolviĆ³ mi problema, gracias!