AX / D365FO – How to add empty ranges in query

I’m setting up a QueryRange and found that if I pass my filter field an empty string the query doesn’t run the range.

I would have expected all records where the range field is empty to be shown but not…

How can I solve this problem? Easy!! Instead of using an empty string I use the SysQuery::valueEmptyString() method

Here is an example

Query                   query;
QueryRun                queryRun;
  
QueryBuildDatasource    qbds;
QueryBuildRange         qbr;

query = new Query();
qbds = query.addDataSource(tableNum(ProjTable));
qbr = qbds.addRange(fieldNum(ProjTable, Name));
  
 qbr.value(SysQuery::valueEmptyString());

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 )

Facebook photo

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

Connecting to %s