Redigera

Dela via


Record.Insert() Method

Version: Available or changed with runtime version 1.0.

Inserts a record into a table without executing the code in the OnInsert trigger.

Syntax

[Ok := ]  Record.Insert()

Parameters

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

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 1

This example shows how to use the Insert method without a return value.

Customer.Init;  
Customer."No." := '1120';  
Customer.Insert();  

If customer 1120 already exists, then a run-time error occurs.

Example 2

This example shows how to use the Insert method with a return value.

var
    CustomerRec: Record Customer;
    Text000: Label 'Customer no: %1 inserted.';
    Text001: Label 'Customer no: %1 already exists.';
begin
    CustomerRec.Init();  
    CustomerRec."No." := '1120';  
    if CustomerRec.Insert() 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