Inserts a record into a C/SIDE table.
|
[Ok :=] Record.INSERT([RunTrigger])
|
Parameters
- Record
-
Type: Record
The record that you want to insert.
- 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.
Property Value/Return Value
Type: Boolean
true if the record was inserted; otherwise,
false.
If you omit this optional return value and if the record cannot
be inserted, a run-time error occurs. If you include the return
value, you must handle any errors.
Remarks
Example
This example shows how to use the INSERT function
without a return value.
|
Copy Code |
Customer.INIT
Customer."No." := '1120';
Customer.INSERT;
|
If customer 1120 already exists, a run-time error
occurs.
This example requires that you create the following
variable and text constants in the C/AL Globals window.
Variable name |
DataType |
Subtype |
CustomerRec
|
Record
|
Customer
|
Text constant name |
ENU value |
Text000
|
Customer no: %1 inserted.
|
Text001
|
Customer no: %1 already exists.
|
|
Copy Code |
CustomerRec.INIT
CustomerRec."No." := '1120';
If CustomerRec.INSERT THEN
MESSAGE(Text000, CustomerRec."No.")
ELSE
MESSAGE(Text001, CustomerRec."No.");
|
No run-time error occurs if customer 1120 already
exists.
See Also