D365/ Ax2012: Custom lookup for customer account with not exist join

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();

 

 

}

Comments

Popular posts from this blog

D365: SSRS Report Development/ Customization

D365: X++ code to add custom lookup on worker to show specific workers team workers only

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"