Example of the lookup.

When you have to create lookup 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