RecordSortedList and RecordInsertList

30 Dec

For those who are wondering, Is there any way in AX to reduce the client server call when inserting a bunch of records into the database. With no surprise Yes!, AX provides a way to do that. Two Collection classes are there in AX RecordSortedList and RecordInsertList for this purpose.

The RecordSortedList class inserts multiple records in a single database trip, and can hold a subset of data from a table, in a particular sort order that does not exist as an index. There are built-in methods in RecordSortedList which can be used to perform the insertion to database. You must provide the sort order in order to perform the insertion properly. The following code sample demonstrates how to insert multiple Student records in the same database trip, using RecordSortedList:


Student student;

RecordSortedList recordSortedList = new RecordSortedList(tablenum(Student));

recordSortedList .sortOrder(fieldname2id(tablenum(Student),’StudentId’));






















The RecordInsertList class provides array insert capabilities in the kernel. This allows you to insert more than one record into the database at a time, which reduces communication between the application and the database.

RecordInsertList is similar to RecordSortedList, but it has built-in client/server support (it automatically packs data from one tier to another when needed), and it lacks the sort order features available in RecordSortedList.


The following is an example using RecordInsertList

Student student;

RecordInsertList insertList = new RecordInsertList(student.TableId, True);

int i;


for ( i = 1; i <= 100; i++ )


student.StudentrId = “F”+int2str(i);





Let me know if you guys have any queries. I will appreciate your comments and feedback.


Posted by on December 30, 2010 in AX, Basics, Dynamics, Framework, Tables, X++


Tags: , , ,

2 responses to “RecordSortedList and RecordInsertList

  1. SebDra

    February 27, 2011 at 6:35 pm

    the kernel decides about the insert… and tries to transfer the records block by block…. don’t know exactly… ~100 records per block

    the kernel will use a record-by-record insert, if:
    -the databaselog for the table-insert is activated
    -an insert-alert is set be any user
    -the insert-method is overwritten

    normally you can deactive these mechanism setting the skip-parameters (e.g. tablehandle.skipdatabaselog(true))
    the recordinsertlist-class has also parameters for them

  2. Darwanto

    February 2, 2015 at 5:23 am

    Hi Zeeshan,

    great post.
    Btw, can u tell me how to select inserted record from temporary table after the records in temporary table is inserted using RecordInsertList ?

    thx in advance


Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: