Let's say we have a table, for example SalesTable. Then we would like to create a lookup with all fields from that table. This below is a simple way we can do in ax 2012.
Solution
So you have a field with lookup (override) method as follows.
In the lookup method, put this below code.
public void lookup()
{
;
YourExampleTable.lookupTableField(this);
}
At YourExampleTable table, insert this below method. You will note that the name of table we'd like to get all lists is from ..tableName2id(this.refTableName). You can change it to fit your need.
public void lookupTableField(FormControl _formControl) { SysTableLookup sysTableLookup = SysTableLookup::newParameters(Tablenum(Utilelements),_formControl); Query query = new Query(); QueryBuildDataSource qbd; ; SysTableLookup.addLookupfield(fieldnum(Utilelements,name)); qbd = query.addDataSource(Tablenum(Utilelements)); qbd.addRange(fieldnum(Utilelements,RecordType)).value(queryvalue(UtilelementType::TableField)); qbd.addRange(fieldnum(Utilelements,ParentId)).value(queryvalue(
tableName2id(this.refTableName)
)); sysTableLookup.parmQuery(query); systableLookup.performFormLookup(); }
That's all!
No comments:
Post a Comment