Using TempDB Tables in AX 2012 Forms

By Becky Newell | July 1, 2015

Having temporary tables stored in the tempDB database is a feature new to AX 2012.  It isn’t difficult to use temporary tables to populate forms but the steps deviate from using InMemory temporary tables with forms.  Given that difference, I thought I would document here how to use tempDB tables as datasources in AX 2012 forms.

1. Create a temporary table with the fields required.  In the property sheet for the table set the TableType property to TempDB.

2. Create a class to populate the temporary table.  For example, in step #1 create a table named TempDBEXampleTable.  Then create a class with a method that populates and returns a populated TempDBExampleTable:

public TempDBExampleTable populateTempTable()


TempDBExampleTable tempTable;

int I;

for(i = 0;i <= 5; i++)


tempTable.Field1 = "string value";

tempTable.Field2 = i;



return tempTable;


3. Create a form and add the TempDBExampleTable as the datasource to the form.

4. In the classDeclaration of the form declare an instance of the TempDBExampleTable table.  (This step isn’t required but this is how I chose to build my form.)

public class FormRun extends ObjectRun


TempDBExampleTable tempTable;


5. In the init method of the form datasource instantiate the class you created in step #2.

6. Still in the datasource’s init method, call the method created in step #2 to populate the temporary table and set the class variable equal to what the method returns.

7. Still in the datasource’s init method, from the buffer for the datasource call the linkPhysicalTableInstance method and pass it the populated temporary table returned in step #6.  The code for the datasource’s init method should look something like this:

public void init()


ClassBuildingTempTable classBuildingTempTable = new ClassBuildingTempTable();


tempTable = classBuildingTempTable.populateTempTable();



Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!