axaptax++dynamics-ax-2012

Filter records in DirPartyTableListPage form


I need to apply ExistsJoin with RestrictionTable to records in DirPartyTable that have InstanceRelation value = 123 and not filter the others in init method in form.

I tried this, but only records with InstanceRelationType == 123 are now in form but i need to keep other as well.

QueryBuildDataSource            qbdsRestriction;
QueryBuildRange                 qbr;


qbdsRestriction = dirpartyTable_ds.queryBuildDataSource().addDataSource(tableNum(RestrictionTable));            
qbr = qbdsRestriction.addRange(fieldNum(RestrictionTable, Party));
qbr.value(strFmt("((%1.Party == %2.RecId) && (%2.InstanceRelationType == 123))", qbdsRestriction.name(), dirpartyTable_ds.queryBuildDataSource().name()));
qbdsRestriction.joinMode(JoinMode::ExistsJoin);

Solution

  • My problem was solved by making a union query for form datasource containing one view that was filtered with exist join and has range of InstanceRelation field = 123 and another view with unlimited value in InstanceRelation field --- the same way it was described here Get customer or prospects in Dynamics AX 2012