How to create lookup of all fields in a table in Dynamics AX 2012 using X++
static void fieldLookup(FormControl _formControl, str _filterStr,TableId _tableId)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup;
QueryBuildRange range;
AXFieldTmp fields;
SysModelElement sysModelElement;
DictField dictField;
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup;
QueryBuildRange range;
AXFieldTmp fields;
SysModelElement sysModelElement;
DictField dictField;
while select sysModelElement
where sysModelElement.ElementType == UtilElementType::TableField
&& sysModelElement.ParentId == _tableId
&& sysModelElement.AxId != 0
{
dictField = new DictField(_tableId,sysModelElement.AxId);
if (!(dictField.name() like "DEL_*"))
{
switch(dictField.baseType())
{
case Types::Real:
case Types::Date:
case Types::UtcDateTime:
fields.clear();
fields.FieldId = sysModelElement.AxId;
fields.FieldName = sysModelElement.Name;
fields.FieldLabel = dictField.label();
fields.insert();
break;
}
}
}
sysTableLookup = SysTableLookup::newParameters(tableNum(AXFieldTmp), _formControl);
queryBuildDataSource = query.addDataSource(tablenum(AXFieldTmp));
sysTableLookup.addLookupField(fieldNum(AXFieldTmp, FieldName));
sysTableLookup.addLookupField(fieldNum(AXFieldTmp, FieldLabel));
sysTableLookup.parmQuery(query);
sysTableLookup.parmTmpBuffer(fields);
sysTableLookup.performFormLookup();
}
Comments
Post a Comment