# OnQueryClosePage (Request Page) trigger
> Version: _Available or changed with runtime version 1.0._
Runs when a page closes and before the OnClosePage trigger executes.
## Syntax
```al
trigger OnQueryClosePage(CloseAction: Action): Ok
begin
    ...
end;
```
### Parameters
CloseAction
Type: ../../methods-auto/action/action-option
The CloseAction chosen by the user; usually OK or Cancel.
## Return value
Ok
Type: ../../methods-auto/boolean/boolean-data-type
true if page was closed, otherwise false. This value is checked after each call. The default value is true.
## Remarks
> IMPORTANT
> The trigger is only invoked when the page is hosted in a modal popup window \(MPO\).
If the page that is closing and all its child pages return true in the OnQueryClosePage trigger, then the ../page/devenv-onclosepage-page-trigger is called for all child pages and then for the parent page.
If an error occurs in the OnQueryClosePage trigger or it returns false, then the page is not closed.
When the OnQueryClosePage trigger is called on a subpage, the CloseAction parameter is set to the same value as the parent page.
You can use this trigger to write to the database.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
../page/devenv-onqueryclosepage-page-trigger
OnQueryClosePage (Request Page Extension) Trigger<../requestpageextension/devenv-onqueryclosepage-requestpageextension-trigger>
OnQueryClosePage (Page Extension) Trigger<../pageextension/devenv-onqueryclosepage-pageextension-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/requestpage/devenv-onqueryclosepage-requestpage-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/requestpage/devenv-onqueryclosepage-requestpage-trigger/
