How to read BAQ results in a BPM?

,

I have the following code that performs the execution of a BAQ.

However, I don’t know how I could extract the results obtained from the query.

Ice.Contracts.DynamicQuerySvcContract tQuery = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(Db);

if (tQuery != null)
{
    Ice.Tablesets.DynamicQueryTableset dsQuery = tQuery.GetByID("test");
    if (dsQuery != null)
    {
        Ice.Tablesets.QueryExecutionTableset dsBAQ = tQuery.GetQueryExecutionParameters(dsQuery); 
        
        DataSet result = tQuery.Execute(dsQuery, dsBAQ);

        //Read rows?

        dsBAQ = null;
    }
    dsQuery = null;
    tQuery.Dispose();
}

foreach(var row in result.Tables[0].Rows)
{
    var someColumnValue = row["ColumnName"];
}

etc

What are you trying to do?

I have to extract the information from the query to insert it in some fields.
But I am having the problem when extracting the values from the query.

Message: CS0021 Cannot apply indexing with [] to an expression of type ‘object’

try : foreach(DataRow row in result.Tables[0].Rows)

2 Likes

The problem was solved.
If I put an external BAQ in the BAQ name, does this work correctly?

yes

I did the test and it works.
Thank you for your help.