AX 2012: Using Temporary Table as Form’s Datasource

First add a method on the form to populate records in the temporary table:

public LabelsTable populateRecords()
    SysDictTable    dictTable = new SysDictTable(tableNum(PurchLine));
    SysDictField    dictField;
    TreeNode        treeNode;
    LabelsTable     labelsTableLocal;                 // Temporary table (InMemory)
    FieldId         fieldId = dictTable.fieldNext(0);

    while (fieldId)
        dictField = dictTable.fieldObject(fieldId);

        if (dictField.isSql() && !dictField.isSystem() && != "Modified")
            treeNode = dictField.treeNode();
            labelsTableLocal.Field =;
            labelsTableLocal.Label = treeNode.AOTgetProperty("Label");

        fieldId = dictTable.fieldNext(fieldId);
    return labelsTableLocal;


Then override form’s init() method and add the following code to display the temporary table data on the form:

public void init()

3 thoughts on “AX 2012: Using Temporary Table as Form’s Datasource

  1. Small point, but if the table is a the type TempDB, then the line LabelsTable.setTmpData(element.populateRecords()) will not work, you need to change it to LabelsTable.linkPhysicalTableInstance(element.populateRecords()) and then all is good

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s