web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Suggested answer
    Martin Dráb Profile Picture
    235,792 Most Valuable Professional on at
    Inserting with RecordInsertList
    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.
  • junior AX Profile Picture
    1,552 on at
    Inserting with RecordInsertList
    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;
        }
    
    }
    }
    
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 665 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 595 Most Valuable Professional

#3
Yng Lih Profile Picture

Yng Lih 558

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans