How to make a query in Ax with advanced filtering (with x++):
I want to make such filter criteria On SalesTable form to show SalesTable.SalesId == "001" || SalesLine.LineAmount == 100
.
So result should show SalesOrder 001 AND other salesOrders which has at least one SalesLine with LineAmount = 100?
The AX select statement supports exists join such as:
X++ does not support
exists
clause as a subquery in thewhere
clause. Therefore it is not possible to express theexists
in combination withor
.However AX supports query expressions in a query.
Therefore your query should be possible to express like this:
However, if sales order 001 does not contain lines, it will not be selected. Other than that the output is as you requested:
Jan's solution works fine if sales order '001' should only be selected if it has sales lines. If it doesn't have lines it won't appear in the output.
If it is important to you that sales order '001' should always appear in the output even if it doesn't have sales lines, you can do it via union as follows: