OnInsert (Table Extension) Trigger

Version: Available or changed with runtime version 1.0.

Runs when a user inserts a new record into the table.

Syntax

trigger OnInsert()
begin
    ...
end;

Remarks

This trigger is run before default insert behavior, which checks that the record to be inserted does not already exist before the insertion occurs. It runs automatically after the user chooses to insert a new record in a page from the Web client. If a user inserts a record using AL code, then the RunTrigger argument of Insert (Record) Method must be set to true for the OnInsert Trigger to run, or otherwise it will not. The new record is not inserted if an error occurs in the trigger code.

In tables where records are entered in pages that have the DelayedInsert Property set to true, we recommend that you write any code that is in an OnInsert trigger so that it will always succeed. For example, this applies to journal lines.

See Also

Get Started with AL
Developing Extensions
OnInsert (Table) Trigger