{"title":"Triggers overview","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/devenv-triggers/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/devenv-triggers, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/devenv-triggers","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn how triggers work in AL for Business Central.","date":"2026-10-01","meta":{"topic":"get-started"},"outline":[{"level":1,"title":"Triggers overview","slug":"triggers-overview","at":0,"chars":2537},{"level":2,"title":"Coding triggers","slug":"coding-triggers","at":815,"chars":554},{"level":2,"title":"Snippet support","slug":"snippet-support","at":1369,"chars":403},{"level":2,"title":"Example","slug":"example","at":1772,"chars":678},{"level":2,"title":"Related information","slug":"related-information","at":2450,"chars":87}],"text":"# Triggers overview\nThis section describes how triggers work in Business Central.\n> TIP\n> If you already know the name of, for example, a data type, method, property, or trigger, use the Filter by title field in the upper left corner, above the table of contents to find the article faster. Otherwise, you can scan the table of contents to find it.\nTriggers activate a method when a certain event occurs. When AL methods are run because of a predefined event on either an object or a control, the event triggers the method. Together the event and method make a trigger.\nTriggers are useful for doing calculations and validations. Compared to properties, they provide a more diverse, effective way of doing such operations. For example, you can use triggers in reports to control how data is selected and retrieved.\n## Coding triggers\nThere are different triggers for the various AL object types. Some triggers are set on the object-level, while others are set on the controls. For example, a table has some triggers on the table object and other triggers on field controls. Or consider reports, which have some triggers on the report object and some on the data items. Trigger are typically added at the end the code block for the object or control. Triggers have the following syntax:\n```al\ntrigger OnWhat()\nvar\n    myVariable: type;\nbegin\n    // Custom code\nend;\n```\n## Snippet support\nTyping the shortcut ttrigger creates the basic layout for a trigger when using the AL Language extension for Microsoft Dynamics 365 Business Central in Visual Studio Code.\n> TIP\n> Use Ctrl+Space to trigger IntelliSense and get assistance on code completion, parameter info, quick info, and member lists. For more information about snippets, see Syntax and snippets<../devenv-syntax>.\n## Example\nThe following example shows the basic trigger layout for a table object.\n```al\ntable 50100 MyTable\n{\n\n    fields\n    {\n        field(1;MyField; Integer)\n        {\n            // Field triggers\n            trigger OnLookup()\n            var\n                myInt: Integer;\n            begin\n\n            end;\n        }\n    }\n\n    keys\n    {\n        key(Key1; MyField)\n        {\n            Clustered = true;\n        }\n    }\n\n    var\n        myInt: Integer;\n\n    // Table object triggers\n    trigger OnInsert()\n    begin\n\n    end;\n\n    trigger OnModify()\n    begin\n\n    end;\n\n    trigger OnDelete()\n    begin\n\n    end;\n\n    trigger OnRename()\n    begin\n\n    end;\n}\n```\n## Related information\nMethods<../methods-auto/library>\n../properties/devenv-properties"}