Calling a BAQ from BPM to get back result to update table

trying to create code that is running inside a BPM .. created a BAQ that returns the primaryBin from the PlantWhse for a part/warehouse.. (passed back to BOM) to update the jobmlt.bin.. but error (CS0246).. (the Type or namespace name ‘DynamicQueryImpl’ could not be found..
I am no expert in C#..
I did use the reference assemblies

// BAQ ID
string baqID = "test-baq";

// Get parameters from BPM context (ShortChar fields are common)
string partNum = this.callContextBpmData.Character01 ?? string.Empty;
string warehouseCode = this.callContextBpmData.Character02 ?? string.Empty;

// Instantiate the BAQ service
var dqSvc = new DynamicQueryImpl(this.Db);

// Get the BAQ parameters
var paramDS = dqSvc.GetQueryExecutionParametersByID(baqID);

// Set parameter values
foreach (var param in paramDS.ExecutionParameter)
{
    if (param.ParameterID == "PartNum")
        param.ParameterValue = partNum;
    else if (param.ParameterID == "WarehouseCode")
        param.ParameterValue = warehouseCode;
}

// Execute the BAQ with parameters
var resultDS = dqSvc.ExecuteByIDWithParams(baqID, paramDS);

// Initialize result variable
string primBin = string.Empty;

// Check if results exist and get value
if (resultDS?.Tables["Results"]?.Rows.Count > 0)
{
    var row = resultDS.Tables["Results"].Rows[0];
    if (row.Table.Columns.Contains("PrimBin"))
    {
        primBin = row["PrimBin"].ToString();
    }
}

// Store result back to BPM context
this.callContextBpmData.ShortChar03 = primBin;

reference assemblies

You need a using statement, or you need to call the whole assembly.

You either need to change this line to this

var dqSvc = new Ice.Contracts.BO.DynamicQueryImpl(this.Db);

or you need to go to the usings tab and add this so it knows that the assembly is available.

using Ice.Contracts.BO;

thank you will try and let you know..
:slightly_smiling_face:

thanks, but tried and still error

// BAQ ID
string baqID = "test-baq";

// Get parameters from BPM context (ShortChar fields are common)
string partNum = this.callContextBpmData.Character01 ?? string.Empty;
string warehouseCode = this.callContextBpmData.Character02 ?? string.Empty;

// Instantiate the BAQ service
//var dqSvc = new DynamicQueryImpl(this.Db);
var dqSvc = new Ice.Contracts.BO.DynamicQueryImpl(this.Db);

// Get the BAQ parameters
var paramDS = dqSvc.GetQueryExecutionParametersByID(baqID);

// Set parameter values
foreach (var param in paramDS.ExecutionParameter)
{
    if (param.ParameterID == "PartNum")
        param.ParameterValue = partNum;
    else if (param.ParameterID == "WarehouseCode")
        param.ParameterValue = warehouseCode;
}

// Execute the BAQ with parameters
var resultDS = dqSvc.ExecuteByIDWithParams(baqID, paramDS);

// Initialize result variable
string primBin = string.Empty;

// Check if results exist and get value
if (resultDS?.Tables["Results"]?.Rows.Count > 0)
{
    var row = resultDS.Tables["Results"].Rows[0];
    if (row.Table.Columns.Contains("PrimBin"))
    {
        primBin = row["PrimBin"].ToString();
    }
}

// Store result back to BPM context
this.callContextBpmData.ShortChar03 = primBin;

error is
image

i am on kinetic 2025.1.8

// BAQ ID
string baqID = "test-baq";

// Get parameters from BPM context (ShortChar fields are common)
string partNum = this.callContextBpmData.Character01 ?? string.Empty;
string warehouseCode = this.callContextBpmData.Character02 ?? string.Empty;

// Instantiate the BAQ service
this.CallService<Ice.Contracts.DynamicQuerySvcContract>(dqSvc=>
{

//var dqSvc = new DynamicQueryImpl(this.Db);

// Get the BAQ parameters
var paramDS = dqSvc.GetQueryExecutionParametersByID(baqID);

// Set parameter values
foreach (var param in paramDS.ExecutionParameter)
{
    if (param.ParameterID == "PartNum")
        param.ParameterValue = partNum;
    else if (param.ParameterID == "WarehouseCode")
        param.ParameterValue = warehouseCode;
}


// Execute the BAQ with parameters
var resultDS = dqSvc.ExecuteByID(baqID, paramDS);

// Initialize result variable
string primBin = string.Empty;

// Check if results exist and get value

if (resultDS?.Tables["Results"]?.Rows.Count > 0)
{
    var row = resultDS.Tables["Results"].Rows[0];
    if (row.Table.Columns.Contains("PrimBin"))
    {
        primBin = row["PrimBin"].ToString();
    }
}

// Store result back to BPM context
this.callContextBpmData.ShortChar03 = primBin;
});

Try that.

hell, still not working

even with the using ICE.contracts.BO or not.. error

Can you show me your reference? In the using and references button?

And while you’re in there, can you double click on the error and see which line it brings you to?

double click line

using window

reference window

You’re missing the assembly for DynamicQuery.

it took forever to appear.. at least 30 sec.. not sure why..
no errors anymore..
thanks, your the best

That slowness is because Epicor is calling for one row at a time. You can put a BPM in there to fix it. I can never find the post, but I have the BPM in place. Below are the screenshots. That takes it from minutes to literally seconds.

edit: here is is. References Dialog Speedup - Works -> (Need a ̶C̶l̶o̶u̶d̶ Guinea Pig) :dumpster_fire: - #33 by klincecum