Microsoft D365 operates with normal databse tables and temporary table based on the requirement in a project, Regular tables are normal standard physical tables in SQL server database. Where as InMemory tables are temporary tables which are held in the memory and written to local disc after reaching a certain limit of the system especially in Application Object Server (AOS).
If you are a beginner or new to dynamics 365 Finance & Operations, you can use Microsoft'f Free Virtual Machine. Learn How to Set Up a Free Virtual Machine for Dynamics 365 Development
Why we Use Normal Table as Temp Table in Dynamics 365 Finance and Operations ?
In Dynamics 365 Finance and Operation projects you can use the following coding snippets to convert a regular table to temp table.
As an example, we will use the vendor table to insert and display a couple of temporary records without affecting actual data.Yo create a Runnable Class named VendTableToTempÂ
class VendTableToTemp
{
public static void main(Args _args)
{
VendTable vendTable;
vendTable.setTmp();
vendTable.AccountNum = '1001';
vendTable.Blocked = CustVendorBlocked::No;
vendTable.Party =Supplier 1;
vendTable.doInsert();
vendTable.clear();
vendTable.AccountNum = '1002';
vendTable.Blocked = CustVendorBlocked::All;
vendTable.Party = Supplier 2;
vendTable.doInsert();
while select vendTable
{
info(strFmt( "%1 - %2", vendTable.AccountNum, vendTable.Name));
}
}
}
Output
1002 - Supplier 2
1001 - Supplier 1
In the code, we first call the setTmp() method on the vendTable table to make it temporary in the scope of this method. This means that any data manipulations will be lost once the execution of this method is over and the actual table content will not be affected.
The key method used here to convert a regular table to temp table is setTmp();ÂNext we will use doInsert() to bypass any validation rules which are not required for temporary table.
We have to keep in mind that even the table becomes temporary; all the code in its insert(), update(), delete(), initValue(), and other methods is still present and we have to make sure that we don't call it unintentionally.
If you like this article please share to your friends and your comment will be very valuable for improving the quality of the articles. So happy coding with D365 Snippets 🙂.