AX – D365FO – “OR” conditions in a QueryBuildRange for a same field

I want to add a list of values in an “OR” Condition for a same field in a QueryBuildRange.

The result must be something like that

select * from CustGroup where custGroup.CustGroup == ’50’ || custGroup.Group ==’90’;

To do that Just add range and assign value on the same field multiple times as shown in code below:

Query                   q;
QueryBuildDataSource    qbds;
QueryRun                qr;
QueryBuildRange         qbr;

q = new Query();
qbds = q.addDataSource(tableNum(CustGroup));
qbr = qbds.addRange(fieldNum(CustGroup,CustGroup));
qbr.value(queryValue('50'));

qbr = qbds.addRange(fieldNum(CustGroup,CustGroup));
qbr.value(queryValue('90'));

info(qbds.toString());

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s