AX / D365FO – Form Control Lookup for all available table names

I want to get a lookup for all available table names in the system. 

I know to achieve this on a dialog but now I want a lookup on a stringedit/combobox on a form.

The only way I know is to create a table with a field bounded to RefTableId/TableName EDT and override the lookup method like shown below

Step 1 : Create a field on your table and bound it to TableName EDT

Step 2 : Create a new form and select your table as Data Source

Step 3 : Override the lookup method with this code

public void lookup()

{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(SYSTABLEIDVIEW), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;

sysTableLookup.addLookupfield(fieldnum(SYSTABLEIDVIEW, SqlName));
sysTableLookup.addLookupfield(fieldnum(SYSTABLEIDVIEW, Id));

queryBuildDataSource = query.addDataSource(tablenum(SYSTABLEIDVIEW));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

et voilà

Leave a comment