TempDB table add to form data source does not populate data

In AX 2012 R2, I’ve create a table where Table Type is tempDB. Later i write a job to build a form from code, populate data from the table method.

When the form run, no data is shown on the form. But, when i query data from infolog, data is shown (successfully insert).

May I know what is the cause that data not show on my form ? Appreciate feedback. Thanks.

static void buildForm(Args _args)

{

Form form;

FormRun formRun;

Args args;

FormBuildDesign formBuildDesign;

FormBuildControl formBuildControl;

FormBuildTabControl formBuildTabControl;

FormBuildTabPageControl formBuildTabPageControl;

FormBuildGridControl formBuildGridControl;

FormBuildDatasource formBuildDatasource;

FormBuildStringControl formString;

DictTable dictTable;

TestTmp testTmp;

form = new Form();

// Add a data source to the form.

dictTable = new DictTable(tablenum(testTmp));

formBuildDataSource = form.addDataSource(dictTable.name());

formBuildDataSource.table(dictTable.id());

testTmp.linkPhysicalTableInstance(testTmp::populateData());

formBuildDesign = form.addDesign(‘design’);

formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, ‘Tab’);

formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, ‘TabPage’);

formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid, ‘Grid’);

formString = formBuildGridControl.addDataField(formBuildDatasource.id(), dictTable.fieldName2Id( “ItemId”));

formString.label(“ItemId”);

formString = formBuildGridControl.addDataField(formBuildDatasource.id(), dictTable.fieldName2Id( “String1”));

formString.label(“String01”);

formString = formBuildGridControl.addDataField(formBuildDatasource.id(), dictTable.fieldName2Id( “String2”));

formString.label(“String02”);

args = new Args();

args.object(form);

formRun = classFactory.formRunClass(args);

formRun.init();

formRun.run();

formRun.wait();

//Check if record exist from infolog

while select testTmp

{

info(strFmt("%1",testTmp.ItemId));

}

}

// Populate data method in temporary table

static TestTmp populateData()

{

TestTmp tmp;

InventTable inventTable;

while select firstOnly10 inventTable

{

tmp.clear();

tmp.initValue();

tmp.ItemId = inventTable.ItemId;

tmp.doInsert();

}

return tmp;

}

Hi,

In Ax 2012 we have 3 different types of tables. one type of temporary table is a TempDB table. We call them TempDB tables because their TableType property value is TempDB. This value comes from the TableType::TempDB enum value. The TableType property value can be set at AOT > Data Dictionary > Tables >MyTempDBTable > Properties > TableType.

  • Regular - a standard
    physical table
  • InMemory - the type
    of temporary table which existed in the previous versions of Dynamics Ax.
    Such tables are held in memory and written to a local disk file once they
    grow beyond a certain point
  • TempDB - a new
    option in Ax 2012. They are “physical” temporary tables held in
    the SQL Server database.

The new TempDB tables operate in a similar manner to InMemory tables but support more features of standard physical tables:

  • More powerful
    joins with physical tables are possible, and are properly supported by the
    database
  • Can be
    per-company or global
  • Support for
    normal tts transactions

To create a new instance link (populating data/copying reference) from one table instance
variable to the other with Temporary type tables:

For more details on TempDB capabilities, Limitations, How to use, Its lifetime please check here - http://msdn.microsoft.com/en-us/library/gg845661.aspx

Hi Varre,

I understand the 3 table types. The reason i set it to TempDB is because i only want to display data during the scope when i run the form. I’ve used linkPhysicalTableInstance() method to retrieve record. I can successfully select data from this TempDB (in the end of my code), but cannot seem to get it display on the form during form run.

Do you have any idea why this happens ?