Enter the key words to find the related topics

How to use Temp table as data source of form in AX 2012

Yes, you can use temporary table as datasource whether it is of type tempDb or InMemory.

I assumed that you have temporary table ready and just need to drag in to the form datasource.

Now, Create one method named insertRecords at form level.

eg.,

TmpTable insertRecords()
{

TmpTable tmpTableBuffer;
OtherTable otherTableBuffer;

while tmpTableBuffer
{
tmpTableBuffer.field1 = otherTableBuffer.field1;
.
.
.
.
.
tmpTableBuffer.fieldn = otherTableBuffer.fieldn;
tmpTableBuffer.insert();
}

Now, call this method in init method of form after super.

public void init()
{

super();

// important thing comes here
// if table is of type InMemory,call following method.

TmpTable.setTmpData(element.insertRecords());

// if table is of type tempDb, call following method.

TmpTable.linkPhysicalTableInstance(element.insertRecords());
}

No comments:

Post a Comment