Different types of query range value assignment (Expressions and conditions as range value) X++ D365FO
In the example below, we construct a query and add a single datasource. The range is then added, using the DataAreaId field on each table. Any field can be used, but using an unusual one such as DataAreaId helps remind a casual reader of the code that it’s not a normal range. query = new Query(); dsInventTable = query.addDataSource(tableNum(InventTable)); // Add our range queryBuildRange = dsInventTable.addRange(fieldNum(InventTable, DataAreaId)); Given the above, the following are valid range specifications: Simple criteria[edit] Find the record where ItemId is B-R14. Take note of the single quotes and parenthesis surrounding the entire expression. queryBuildRange.value(strFmt('(ItemId == "%1")', queryValue("B-R14"))); Find records where the ItemType is Service. Note the use of any2int(). queryBuildRange.value(strFmt('(ItemType == %1)', any2int(ItemType::Service))); Find records where the ItemType is Service or the ItemId is B-R14. Note the nesti