Ax 2012

when writing lookups

When you create lookups and don’t know all details by heart, this example proves to be really useful. It was found somewhere in the Internet, so if you know where it is taken from please comment and I will link to the author blog post.

 

Query query = new Query();
 QueryBuildDataSource qbds;
 QueryBuildDataSource qbdsJoin;
 SysTableLookup sysTableLookup = sysTableLookup::newParameters( tableNum(VendTable), this);
 ;
 
 qbds= query.addDataSource( tableNum(VendTable));
 qbdsJoin= qbds.addDataSource( tableNum(DirPartyTable));
 qbdsJoin.relations( false);
 qbdsJoin.fields().dynamic(NoYes::Yes);
 qbdsJoin.addLink( fieldNum(VendTable, Party), fieldNum(DirPartyTable, RecId));
 qbdsJoin.joinMode(JoinMode::InnerJoin);
 
 sysTableLookup.parmQuery(query);
 sysTableLookup.addLookupfield( fieldNum(VendTable, AccountNum), true);
 sysTableLookup.addLookupfield( fieldNum(VendTable, VendGroup), true);
 sysTableLookup.addLookupfield( fieldNum(VendTable, Party));
 sysTableLookup.performFormLookup();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s