Record.Insert(Boolean, Boolean) Method

Version: Available or changed with runtime version 4.0.

Inserts a record into a table.

Syntax

[Ok := ]  Record.Insert(RunTrigger: Boolean, InsertWithSystemId: Boolean)

Parameters

Record
 Type: Record
An instance of the Record data type.

RunTrigger
 Type: Boolean
If this parameter is true, the code in the OnInsert Trigger is executed. If this parameter is false, the code in the OnInsert trigger is not executed. The default value is false.

InsertWithSystemId
 Type: Boolean
If this parameter is true, the SystemId field of the record is given a value that you explicitly assign. If a value is not assigned, then the platform assigns one. If this parameter is false, the SystemId field is given a value that is auto-generated by the platform. The default value is false.

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

The inserted record will automatically get assigned a SystemId by the platform. To assign a specific SystemId instead of the one assigned by the platform, use Insert(Boolean, Boolean) instead.

Example

This example shows how to use the Insert method to insert a record with a specified SystemId.

var
    CustomerRec: Record Customer;
    Text000: Label 'Customer no: %1 inserted.';
    Text001: Label 'Customer no: %1 already exists.';
begin
    CustomerRec.Init(); 
    CustomerRec."No." := '1120'; 
    CustomerRec.SystemId := '{B6666666-F5A2-E911-8180-001DD8B7338E}';  
    if CustomerRec.Insert(true, true) then  
      Message(Text000, CustomerRec."No.")  
    else  
      Message(Text001, CustomerRec."No.");
end;

No run-time error occurs if customer 1120 already exists.

SystemId Field
Record Data Type
Get Started with AL
Developing Extensions