How to create lookup of all tables in Dynamics AX 2012 using X++
static void tableLookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup;
QueryBuildRange range;
AXTableTmp tables;
SysModelElement sysModelElement;
DictTable dictTable;
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup;
QueryBuildRange range;
AXTableTmp tables;
SysModelElement sysModelElement;
DictTable dictTable;
while select sysModelElement
where sysModelElement.ElementType == UtilElementType::Table
// && sysModelElement.ParentId == _tableId
&& sysModelElement.AxId != 0
{
dictTable = new DictTable(sysModelElement.AxId);
if (!dictTable.isSystemTable())
{
tables.clear();
tables.Id = sysModelElement.AxId;
tables.TableName = sysModelElement.Name;
tables.TableLabel = dictTable.label();
tables.insert();
}
}
sysTableLookup = SysTableLookup::newParameters(tableNum(AXTableTmp), _formControl);
queryBuildDataSource = query.addDataSource(tablenum(AXTableTmp));
sysTableLookup.addLookupField(fieldNum(AXTableTmp, TableName));
sysTableLookup.addLookupField(fieldNum(AXTableTmp, TableLabel));
sysTableLookup.parmQuery(query);
sysTableLookup.parmTmpBuffer(tables);
sysTableLookup.performFormLookup();
}
Comments
Post a Comment