You can use "Outer join" instead of "Delayed" and then programmatically change the connection mode when there is a field search in HRMVirtualNetworkTable.
Add this method to the SysQuery class:
static void updateJoinMode(QueryBuildDataSource qds) { Counter r; if (qds) { qds.joinMode(JoinMode::OuterJoin); for (r = 1; r <= qds.rangeCount(); r++) { if (qds.range(r).value() && qds.range(r).status() == RangeStatus::Open) { qds.joinMode(JoinMode::InnerJoin); break; } } } }
In execQuery () on an EmplTable data source:
public void executeQuery() {; SysQuery::updateJoinMode(this.queryRun() ? this.queryRun().query().dataSourceTable(tableNum(HRMVirtualNetworkTable)) : this.query().dataSourceTable(tableNum(HRMVirtualNetworkTable))); super(); }
Sometimes this.queryRun () returns null, so use this.query () instead.
Update:
Note that this does not apply to AX 2012 and later, where you can use query filters in external connections. See How to use the QueryFilter class with external joins .
source share