AX – D365FO – How to use Normal Table as Temp Table?

setTmp() : has nothing to do with deletion at all. It turns a buffer to a temporary one, therefore it saves records to memory/on disk instead of into database. If you delete everything from the temporary buffer, it doesn’t delete anything in database, obviously.

So any data manipulations will be lost once the execution of this method is over and actual table content will not be affected.

Will use doInsert() to bypass any validation rules which are not required for temporary table.

As an example, we will use the vendor table to insert and display a couple of temporary
records without affecting actual data.

1. In AOT, create a new class called VendTableTmp with the following code:


class VendTableTmp
{
}
server static void main(Args _args)
{
   VendTable vendTable;

   vendTable.setTmp();
   vendTable.AccountNum = ’1000′;
   vendTable.Name = ‘Vendor 1′;
   vendTable.PartyId = ’1′;
   vendTable.doInsert();
   vendTable.clear();
   vendTable.AccountNum = ’1002′;
   vendTable.Name = ‘Vendor 2′;
   vendTable.PartyId = ’2′;
   vendTable.doInsert();
   while select vendTable
   {
    info(strfmt(“%1 – %2″,vendTable.AccountNum,vendTable.Name));
   }
}

2. Run the class to see results:

1000 Vendor 1

1002 Vendor 2

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s