This is almost the same thing as this post X++ | d365FO - Create a list of table name lookup, but in AX2012.
Thanks Muhammad Afsar Khan here as the original source code and idea comes from his post Display all/specific AOT tables in a lookup.
The overview processes are very similar to D365FO version, but now we don't need to create the temp table:
- Add a lookup method to the table that will be used as a form's data source
- Add a lookup method to the form control
1. Add a lookup method to the table that will be used as a form's data source
public void lookupClassName(FormStringControl _control)
{
QueryBuildDataSource qbds;
Query q = new Query();
SysTableLookup lookup = SysTableLookup::newParameters(tableNum(UtilidElements), _control, true);
qbds = q.addDataSource(tablenum(UtilidElements));
qbds.addRange(fieldnum(UtilidElements, recordType)).value(SysQuery::value(UtilElementType::Class));
//qbds.addRange(fieldnum(UtilidElements, name)).value(SysQuery::value("ABC*"));
//qbds.addSortField(fieldNum(UtilidElements, name), SortOrder::Ascending);
lookup.addLookupField(fieldnum(UtilidElements, Name), true);
lookup.parmQuery(q);
lookup.performFormLookup();
}
2. Add a lookup method to the form control
public void lookup() { //super();
[OurTableName]
.lookupClassName(this); }
No comments:
Post a Comment