{"title":"OnInit (Page) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/page/devenv-oninit-page-trigger/","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/page/devenv-oninit-page-trigger, 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/page/devenv-oninit-page-trigger","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":"Initializes the user-defined variables on the page.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":112,"chars":56},{"level":2,"title":"Remarks","slug":"remarks","at":168,"chars":608},{"level":2,"title":"Related information","slug":"related-information","at":776,"chars":197}],"text":"> Version: _Available or changed with runtime version 1.0._\nInitializes the user-defined variables on the page.\n## Syntax\n```al\ntrigger OnInit()\nbegin\n    ...\nend;\n```\n## Remarks\nThe AL code in this trigger is run immediately after the variables are cleared and the page is loaded. This trigger cannot be used to access the controls on the page. You can change properties that are dynamic, including those properties that can only be changed when the page is opened.\nAfter this trigger is executed, the devenv-onopenpage-page-trigger for pages is called. If an error occurs in the trigger code, then the page is closed.\n> NOTE\n> The OnInit trigger does not support calls to control add-in methods and properties because the trigger is invoked before the page is instantiated.\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnInit (Request Page) Trigger<../requestpage/devenv-oninit-requestpage-trigger>"}