Wednesday, October 11, 2023

RecordInsertList in Dynamics 365 FO

In this blog of Dynamics Community 101 we will learn RecordInsertList in Microsoft Dynamics 365 F&O


In Dynamics 365 Finance & Operations (F&O), the RecordInsertList class is a helpful mechanism for efficiently inserting multiple records into a database table. It's more efficient than using a standard insert in a loop as it batches the inserts, reducing the number of database operations.

Here's a simple example that involves the CustTable, which stores customer information.

Declare a variable of RecordInsertList type - Declare a variable that references a RecordInsertList object. Specify the table you're working with; in this case, the CustTable.

Create the records - Use the new keyword to create a CustTable buffer, and then assign the fields' values.

Add the records to the RecordInsertList - Use the add method on your RecordInsertList object to add each record to the list.

Insert the records - Call the insertDatabase method to insert all the records in the list into the database.

Here's a code snippet to illustrate these steps:

static void InsertCustTableExample(Args _args)


    CustTable custTable;

    RecordInsertList recordInsertList = new RecordInsertList(tableNum(CustTable));

    // Loop to create records

    for (int i = 1; i <= 10; i++)


        custTable.AccountNum = strFmt("CUST%d", i);

        custTable.Name = strFmt("Customer %d", i);


        // Add the record to the RecordInsertList



    // Insert the records into the database


    info("Records inserted successfully.");


This example will insert 10 records into the CustTable. By using RecordInsertList, you're making the insertion more efficient compared to standard insert operations in a loop. It's a useful tool to have in your arsenal, particularly when dealing with large data sets.

If you've made it this far, please leave a kind word. Your encouragement fuels my desire to produce and share even more valuable content.