≡ Menu

Custom lookup field with no exist join records dynamics Ax 2012

During customization I got requirement that in drop down or lookup shows those customer which did not have sales line.

I handle this customization with the help of no exist join.  Code snippet is something like.

 

 

public void lookup()

{

Query query = new Query();

QueryBuildDataSource queryBuildDataSource, qbds, dsView;

QueryBuildRange queryBuildRange;

 

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable), this);

 

sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));

sysTableLookup.addLookupField(fieldNum(CustTable, Party), false);

 

queryBuildDataSource = query.addDataSource(tableNum(CustTable));

 

qbds = queryBuildDataSource.addDataSource(tableNum(DirPartyTable));

qbds.joinMode(JoinMode::InnerJoin);

qbds.addLink(fieldNum(CustTable, Party), fieldNum(DirPartyTable, RecId));

 

dsView =queryBuildDataSource.addDataSource(tableNum(SalesLine));

dsView.joinMode(JoinMode::NoExistsJoin);

dsView.addLink( fieldNum(Salesline, CustomerAccount),fieldNum(CustTable, AccountNum));

 

 

sysTableLookup.parmQuery(query);

 

sysTableLookup.performFormLookup();

 

 

}

 
{ 0 comments… add one }

Leave a Comment