To display the triggers with the table open in Visual Studio Code, enter the trigger keyword in the first line after the fields section, followed by Ctrl + spacebar. This is shown in the following screenshot:
The code contained in trigger is executed prior to the event represented by trigger. In other words, the code in the OnInsert() trigger is executed before the record is inserted into the table. This allows the developer a final opportunity to perform validations and to enforce data consistency such as referential integrity. We can even abort the intended action if data inconsistencies or conflicts are found.
These triggers are automatically invoked when record processing occurs as the result of user action. But when table data is changed by AL code or by a data import, the AL code or import process determines whether or not the code in the applicable trigger is executed:
- OnInsert(): This is executed when a new record is to be inserted in...