Hello All,

Here’s the scenario,

I need to be able to create a table, lets call it TABLE A, that allows for one to have a lookup of all other tables I have in my AOT. Now in my TABLE A, I want to have two columns, one that selects the table and a second column, B that selects a table field from the table specified in column A.

After doing this, I expect to have a TABLE B that will now just be looking up column B (the one with the fields) from table A

Is this doable and if yes, could one of you kindly guide me on how to go about it soonest possible.

May be share an XPO even :slight_smile:



I’m not sure exactly what you are after, but this should get you started. It is currently written to insert into a SQL Server table, but modifying it to insert into an AX table should be easy enough.


static voidProcessTablesFields(Args _args)



TableId tableId;

TableName tableName;

FieldId fieldId;

FieldName fieldName;

Label label =

new Label();

str sqlInsertCommand;

TreeNode treeNodeTables;

TreeNode treeNodeTable;

TreeNode treeNodeFields;

TreeNode treeNodeField;

int nodeCountTables;

int nodeNumberTables;

int nodeCountFields;

int nodeNumberFields;

treeNodeTables = TreeNode::findNode(#TablesPath);

nodeCountTables = treeNodeTables.AOTchildNodeCount();

treeNodeTable = treeNodeTables.AOTfirstChild();

for (nodeNumberTables = 1; nodeNumberTables <= nodeCountTables; nodeNumberTables++)


tableId = treeNodeTable.AOTgetProperty(


tableName = treeNodeTable.AOTgetProperty(


treeNodeFields = TreeNode::findNode(#TablesPath +

“\” + tableName + “\Fields”);

nodeCountFields = treeNodeFields.AOTChildNodeCount();

treeNodeField = treeNodeFields.AOTfirstChild();

for (nodeNumberFields = 1; nodeNumberFields <= nodeCountFields; nodeNumberFields++)


fieldId = treeNodeField.AOTGetProperty(


fieldName = treeNodeField.AOTGetProperty(


sqlInsertCommand =

strFmt("INSERT INTO AX2012R2_XXX.dbo.AxTablesFields (TableId, TableName, FieldId, FieldName) " +

“Values (%1, ‘%2’, %3, ‘%4’)”, tableId, tableName, fieldId, fieldName);


treeNodeField = treeNodeField.AOTNextSibling();


treeNodeTable = treeNodeTable.AOTNextSibling();



“Processing of AOT Tables/Fields complete”);


This thread is a duplicate of another one in the developer forum. Because it’s off-topic here in the technical forum, I’m locking it. Continue the discussion in the developer forum.