Tuesday, February 19, 2019

D365FO RecordInsertList

While traversing on while loop it's always not necessary to insert each record separately. There is another good way to do this; it is using RecordInsertList. It will minimize the number of hits to database. Here is code snippet to use it:


    RecordInsertList    recordInsertList = new RecordInsertList(tableNum(YourTargetTable));     
    YourTargetTable     yourTargetTable;

    while select  tabel1
    join table2
     where table1.RecId == table2.table1
    {
          yourTargetTable.clear();
          yourTargetTable.FirstField   = table1.AnyField;
          yourTargetTable.SecondField  = table2.AnyField;
          yourTargetTable.ThirdField   = table1.AnyField1 + table2.AnyField1;
          recordInsertList.add(yourTargetTable);
    }
   
    recordInsertList.insertDatabase();

No comments:

Post a Comment