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

Inserting with RecordInsertList

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

I have a customized table with the following properties:
cache lookup: NotInTTS
Table Group: Transaction
AllowRowVersionChangeTracking: Yes
ValidTimeStateFieldType: None
The insert method doesn't have any code
 
Currently I'm inserting to this table using RecordInsertList  via batch. However i can see that records are being inserted to the table even though the batch is still executing. And the number of records inserted increases each certain amount of time. So it seems InsertToDatabase is not inserting eveything at once, it's inserting each group together. I'm currently importing more than 100,000 record.  At first the were around 240 records then i selected the table in SQL and they suddenly became 790, then 1370 etc..
Shouldn't it insert them all at once or is this normal? or is there a fallback?

i'll put the code in the first comment so that the code appears clearly
 
I have the same question (0)
  • junior AX Profile Picture
    1,552 on at
    Imagine code starts with run method
    class x extends classZBatch
    {
      private RecordInsertList  recordInsertList = new RecordInsertList(tableNum(TableA));
    
      public void run()
      {
        this.process();
        this.postProcess();
      }
    
      public void postProcess() {
    
        recordInsertList.insertDatabase();
      }
    
      void process() 
      {
        str line;
        const str fieldDelimiter = '\r\n';
        const str recordDelimiter = '\r\n';
        importFile.inFieldDelimiter(fieldDelimiter);
        importFile.inRecordDelimiter(recordDelimiter);
        while (importFile.status() == IO_Status::Ok)
        {
          line = conPeek(importFile.read(), 1);
    
          ttsbegin;
    
          this.processLine(line);
    
          ttscommit;
    
        }
      }
      protected void processLine(str _line) 
      {
        ClassA process = classA::newFromEnumX(EnumX::First);
        process.insertTableA(_line);
        recordInsertList = process.getRecordInsertList();
      }
    }
    
    
    abstract class classA
    {
        private TableA   tableA;
    
        private RecordInsertList recordInsertList = new RecordInsertList(tableNum(TableA));
    
    
        final public void insertTableA(str _line)
        {
    
            tableA.clear();
            // logic to fill table A
            
            recordInsertList.add(tableA);
    
        }
    
    
        public static ClassA newFromEnumX(EnumX _enumX)
        {
            EnumXAtrribute enumXAttribute = new EnumXAtrribute(_enumX);
            return SysExtensionAppClassFactory::getClassFromSysAttribute(classStr(ClassA), enumXAttribute);
        }
    
    
        public RecordInsertList getRecordInsertList()
        {
            return recordInsertList;
        }
    
    
    }
    
    
    class EnumXAtrribute extends SysAttribute implements SysExtensionIAttribute
    {
        EnumX enumX;
    
        public void new(EnumX _enumX)
        {
            super();
    
            enumX = _enumX;
        }
    
        public str parmCacheKey()
        {
            return classStr(EnumXAtrribute) + ';'+ int2str(enum2int(enumX));
        }
    
        public boolean useSingleton()
        {
            return true;
        }
    
    }
    }
    
     
  • Suggested answer
    Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at
    That's correct - the purpose of RecordInsertList is not holding all records in memory and insert them at once. It inserts records in smaller chunks automatically; insertToDatabase() is used at the end to process remaining records that haven't been inserted yet.
     
    If you aren't sure how something should work, you can look into documentation: RecordInsertList Class.

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... 583 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 378

#3
Diego Mancassola Profile Picture

Diego Mancassola 255

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans