web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get data from a tmp table, that was inserted via RecordInsertList.InsertDatabase()

(0) ShareShare
ReportReport
Posted on by 1,552
Hi,

If i've insterted data to a tmpDB table using recordInsertList, how can i loop through the table and get the records inside it

RecordInsertList    tmpDBTableRecordInsertList = new RecordInsertList(tableNum(TmpDBTable));
 
while //logic
{
TmpDBTable tmpDBTable;
tmpDBTable.Field1 = Table1.Field1
tmpDBTable.Field2 = Table1.Field2
 
tmpDBTableRecordInsertList.Add(tmpDBTable);
}
tmpDBTableRecordInsertList.InsertDatabase();

how can i now while loop through all the values that i inserted to the tmp table?
 
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    303,481 Super User 2026 Season 1 on at
    Hi Junior AX,
     
    I would suggest using ttsbegin and ttscommit to define a transaction scope. Then you can use the while select statement to loop the records. Note that the loop should be done in the same logic. If you have one process creating records in the temporary table and another process to loop them, then the table is empty. 
  • junior AX Profile Picture
    1,552 on at
    Hi Andre,

    i did this quickly in a runnable class but it didn't work, the code didn't get inside the while loop for the tmp table -- what am i missing? what did you mean by "the loop should be done in the same logic"?
    internal final class RunnableClass1
    {
        /// <summary>
        /// Class entry point. The system will call this method when a designated menu 
        /// is selected or when execution starts and this class is set as the startup class.
        /// </summary>
        /// <param name = "_args">The specified arguments.</param>
        public static void main(Args _args)
        {
            RecordInsertList    tmpDBTableRecordInsertList = new RecordInsertList(tableNum(TmpDBTable));
    
            ttsbegin;
            TmpDBTable tmpDBTable;
            tmpDBTable.Field1 = 2;
            tmpDBTable.Field2 = 2;
    
            tmpDBTableRecordInsertList.add(tmpDBTable);
    
            tmpDBTable.clear();
            tmpDBTable.Field1 = 1;
            tmpDBTable.Field2 = 1;
    
            tmpDBTableRecordInsertList.add(tmpDBTable);
    
            tmpDBTable.insertDatabase();
            ttscommit;
    
            while select tmpDBTable
            {
                Info(int642Str(tmpDBTable.Field1));
            }
        }
    
    }
     
  • GirishS Profile Picture
    27,833 Moderator on at
    Hi JuniorAX,
     
    Your code is wrong, and it must throw compilation errors. You are calling insertDatabase using the table buffer. It must be buffer for RecordInsertList.
    Also please remove the tempDBTable.clear() line from your code.
    Also, in explanation to the original post - There is no method available to loop through records from RecordInsertList - I would suggest you to create new list type variable and insert the values to the list inside the while select statement. Later you can use ListEnumerator to loop through the records.
     
    Thanks,
    Girish S.
  • Suggested answer
    Martin Dráb Profile Picture
    238,863 Most Valuable Professional on at
    Your code is incorrect - if you want to use RecordInsertList with a temporary table, you must specify the temporary table buffer (to insert records to) in the seventh argument of RecordInsertList().
     
    You can simply query this table buffer after RecordInsertList added records there.
     
    You're declaring a new temporary buffer inside the loop, each of them will almost immediately cease to exist. Both is wrong. You want to insert all records to single buffer and you don't want to immediately throw it away, otherwise there would be no point in insert records to it.
  • junior AX Profile Picture
    1,552 on at
    Hi Martin and Girish,

    Apologies this is a typo, the original code definitely inserts to the database with the recordInsertList buffer, just like the original question shows.
    I removed the clear but still same issue, the while loop for the tmpDB is empty
     
    internal final class RunnableClass1
    {
        /// <summary>
        /// Class entry point. The system will call this method when a designated menu 
        /// is selected or when execution starts and this class is set as the startup class.
        /// </summary>
        /// <param name = "_args">The specified arguments.</param>
        public static void main(Args _args)
        {
            RecordInsertList    tmpDBTableRecordInsertList = new RecordInsertList(tableNum(TmpDBTable));
    
            ttsbegin;
            TmpDBTable tmpDBTable;
            tmpDBTable.Field1 = 2;
            tmpDBTable.Field2 = 2;
    
            tmpDBTableRecordInsertList.add(tmpDBTable);
    
            //tmpDBTable.clear();
            tmpDBTable.Field1 = 1;
            tmpDBTable.Field2 = 1;
    
            tmpDBTableRecordInsertList.add(tmpDBTable);
    
            tmpDBTableRecordInsertList.insertDatabase();
            ttscommit;
    
            while select tmpDBTable
            {
                Info(int642Str(tmpDBTable.Field1));
            }
        }
    
    }
     
  • Martin Dráb Profile Picture
    238,863 Most Valuable Professional on at
    It seems you missed first two sentences of my previous reply.
     
    You must use the table buffer (tmpDBTable) as the seventh parameter of RecordInsertList's constructor. That's what defines to which buffer the records will be inserted to. It also means that you must declare the table buffer before creating the insert list.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 527 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 473

#3
Adis Profile Picture

Adis 284 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans