Query expressions in range

Hi,

I wanted to find multiple items from the InventTable table.

I wanted to execute a query equivalent to “Select * from InventTable where InventTable.ItemId in (‘ItemA’, ‘ItemB’, ‘ItemC’)”. This will give me the 3 records with ItemA, ITemB and ItemC from the InventTable.

Please suggest me the equivalent query statement in AX 2012.

Thanks in advance

Hi Ashlesh,

Using query you can get in this way:

static void Job46(Args _args)

{

Query q = new Query();

InventTable InventTable;

itemid a,b,c;

QueryBuildDataSource qbds;

QueryBuildRange qbr;

QueryRun queryRun;

;

a = ‘001’;

b = ‘123’;

c = ‘1tyf’;

qbds= q.addDataSource(tablenum(InventTable));

qbr = qbds.addRange(fieldnum(InventTable,ItemId));

qbr.value(strFmt(’(%1 || (%2 ||%3))’, a, b, c));

queryRun = new QueryRun(q);

while (queryRun.next())

{

InventTable= queryRun.get(TableNum(InventTable));

info(strfmt("%1" ,InventTable.ItemId));

}

}

Hi,

http://msdn.microsoft.com/en-us/library/aa638454.aspx

http://msdn.microsoft.com/en-us/library/aa893981.aspx

this might help you…

Hi Vishal,

Thanks for the quick reply. That helped.