Dynamic Lookup


I have wriiten this code in Design ->StringCode,the code is working properly

public void lookup()

Query query=new Query();
QueryBuildDataSource qbds,qbds1;
QueryBuildLink qblink1;

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable), this);
qbds = query.addDataSource(tableNum(CustTable));

qblink1 = qbds1.addLink(FieldNum(CustTable, Party),FieldNum(DirPartyTable,RecId));

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

// super();

I’m getting following output but according to my code Party field should be there in lookup containing RecId of DirPartyTable. Why i’m getting Name in lookup??

What is the logic? Plz suggest


Because the surrogate key (RecId) would be useless for users, therefore it’s automatically replaced by something more useful. Look at Replacement groups in AX 2012.

You even don’t need DirPartyTable data source in your query.

Hi Martin,

I’m displaying name in lookup by using sysTableLookup.addLookupField(fieldNum(CustTable, Party)),its working fine.
Now i don’t want to use party field or replacement key…can u tell any method for displaying name corresponding to customer account of cust Table??

What you’re trying to achieve? To display name as before, but to do it somehow manually instead of getting it done automatically? Why?

Hi Martin,

I’m asking for an alternate method for display name as usual but i don’t want to use party field of Custtable??
For a moment Suppose replacement key is not defined for custtable.

To return data from several tables without replacement groups, you would need SysMultiTableLoookup class.