Summary

Completed

In this module, you learned how to work with different object triggers. Table triggers, such as OnInsert, OnModify, and OnDelete, are always run before the action is run on the database. For example, OnInsert is triggered before the actual insert in the database.

To validate user input, you can use the OnValidate trigger on the table fields.

The page object also has triggers; the most frequently used are OnInit, OnOpenPage, and OnAfterGetRecord. You can also find triggers on the different page controls. The OnValidate trigger is available on the table fields and on the page fields. The best place to code the OnValidate trigger is on the table fields because this code is available everywhere that the table is used.

Additionally, you learned about event-based architecture, which is the recommended (and, sometimes, the only) solution to intercept with or integrate your code in the base application code. In different codeunits, tables, and pages, Microsoft created several event publishers that, as a developer, you can subscribe to. For every trigger that's on the table or page level, trigger events are automatically generated.