# OnInit (Page) trigger
> Version: _Available or changed with runtime version 1.0._
Initializes the user-defined variables on the page.
## Syntax
```al
trigger OnInit()
begin
    ...
end;
```
## Remarks
The 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.
After 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.
> NOTE
> The OnInit trigger does not support calls to control add-in methods and properties because the trigger is invoked before the page is instantiated.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
OnInit (Request Page) Trigger<../requestpage/devenv-oninit-requestpage-trigger>

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. https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/page/devenv-oninit-page-trigger/
