Multiple values in query range value in Dynamics AX 2012
Asked Answered
B

2

5

How to build query with multiple values. I need to create filter which display only active BOMs in grid and I looking for solution. Here is my code which isnt working:

public void executeQuery() 
{
QueryBuildRange         qbr;
QueryRun                queryRun;
Query q = new Query();

qbr = SysQuery::findOrCreateRange(BOMTable_q.dataSourceTable(tableNum(BOMTable)), fieldNum(BOMTable, BOMId));

if (activeButton==false)
{
    qbr.value(SysQuery::valueUnlimited());
}   
else
{
    while select BOMVersion where BOMVersion.Active==true && BOMVersion.Approved==true{
    qbr.value(queryValue(BOMVersion.BOMId));
}
super();
Bazaar answered 17/10, 2014 at 13:4 Comment(0)
C
8

You have two options:

  1. add multiple ranges
  2. add multiple values to one range separated by commna

Option 1:

QueryBuildDataSource qbds = q.dataSourceTable(BOMTable);
QueryBuildRange qbr;
while (...)
{
    qbr = qbds.addRange(fieldNum(BOMTable, BOMId));
    qbr.value(queryValue(BOMVersion.BOMId));
}

Option 2:

QueryBuildRange qbr = q.dataSourceTable(BOMTable).addRange(fieldNum(BOMTable, BOMId));
container c;
while (...)
{
    c+= queryValue(BOMVersion.BOMId);
}
qbr.value(con2str(c));
Centri answered 17/10, 2014 at 13:28 Comment(0)
N
0

use like below

query.dataSourceTable(tableNum(BOMTable)).addRange(Fieldnum(BOMTable, Approved)).value(strFmt('((%1.%3 == 0) || (%2.%4 == 0))',
                    query.dataSourceTable(tablenum(BOMTable)).name(),
                    query.dataSourceTable(tablenum(BOMVersion)).name(),
                    fieldStr(BOMTable,Approved),
                    fieldStr(BOMVersion,Approved))); 
Nucleon answered 23/8, 2022 at 12:6 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Garett

© 2022 - 2024 — McMap. All rights reserved.