AX select supports connection support, for example:
while select salesTable exits join salesLine where salesLine.SalesId == salesTable.SalesId && salesLine.LineAmount == 100
X ++ does not support the exists clause as a subquery in the where clause. Therefore, it is impossible to express exists in combination with or .
However, AX does support query expressions in the request.
Therefore, your request should be able to express the following:
static void TestQuery(Args _args) { SalesTable st; QueryRun qr = new QueryRun(new Query()); QueryBuildDataSource qst = qr.query().addDataSource(tableNum(SalesTable)); QueryBuildDataSource qsl = qst.addDataSource(tableNum(SalesLine)); str qstr = strFmt('((%1.SalesId == "%2") || (%3.LineAmount == %4))', qst.name(), queryValue("001"), qsl.name(), queryValue(100)); qsl.relations(true);
However, if sales order 001 does not contain rows, it will not be selected. In addition, the output for your request:
((SalesTable_1.SalesId == "001") || (SalesLine_1.LineAmount == 100))
SELECT FIRSTFAST * FROM SalesTable EXISTS JOIN FIRSTFAST * FROM SalesLine WHERE SalesTable.SalesId = SalesLine.SalesId AND ((((SalesTable_1.SalesId == "001") || (SalesLine_1.LineAmount == 100)))))
001
125
175
source share