In this article we will see how to define extended query ranges using expressions. These expressions can be used in any query where you need to express a range that is more complex than is possible with the usual range value notations. The rules for creating query range value expressions are: Enclose the whole expression in parentheses. Enclose all subexpressions in parentheses. Use the relational and logical operators available in X++. Only use field names from the range's data source. Use the dataSource.field notation for fields from other data sources in the query. Values must be constants in the expression, so any function or outside variable must be calculated before the expression is evaluated by the query. This is typically done by using the strFmt function. Let's do it with some examples: OR clause on same field: Query q; QueryBuildDataSource qbd; QueryBuildRange qbr; q = new Query(); qbd = q.addDataSource(TableNum(CustTable)); q...