RecordInsertList.add Method [AX 2012]

Adds a record to a RecordInsertList object for subsequent insertion into the database.

public int add(Common record)

Run On

Called

Parameters

record
Type: Common Table
A database buffer of the same type with which the class is instantiated.

Return Value

Type: int
An integer that indicates whether the record has been successfully added to the list.

The add method can flush records to the database whenever it will speed up performance. However, to ensure that all records in the list are inserted, use the RecordInsertList.insertDatabase method.

The following example uses RecordInsertList to copy a bill of materials (BOM) from one BOM to another. The add method is used to add all the records in the BOM to the RecordInsertList before a final call is made to the insertDatabase method to insert all remaining records.

void copyBOM(BOMId _FromBOM, BOMId _ToBOM) 
{ 
    RecordInsertList BOMList; 
    BOM BOM, newBOM; 
  
    BOMList = new RecordInsertList(tableNum(BOM)); 
  
    while select BOM 
    where BOM.BOMId == _FromBOM 
    { 
        newBOM.data(BOM); 
        newBOM.BOMId = _ToBOM; 
        BOMList.add(newBOM); 
    } 
    BOMList.insertDatabase(); 
}

Community Additions

ADD
Show: