12
The page trigger OnQueryClosePage exposes a CloseAction parameter. This allows code to only process when the CloseAction = Action::OK.
The integration event OnQueryClosePageEvent does NOT expose the CloseAction so a codeunit subscribing to that event cannot tell if the page was being canceled or not. Obviously, most of the time you don't want any code to run if the page is being canceled.
The kludgy work around is to do a PageExtension for a given page and trap trigger OnQueryClosePage and then call an event subscriber codeunit procedure to set it up. It would then available to the codeunit when the OnQueryClosePage is subscribed.
A cleaner and simpler solution is to expose the CloseAction in the integration event OnQueryClosePageEvent. Then a subscriber codeunit could directly determine whether or not its code should run.
The integration event OnQueryClosePageEvent does NOT expose the CloseAction so a codeunit subscribing to that event cannot tell if the page was being canceled or not. Obviously, most of the time you don't want any code to run if the page is being canceled.
The kludgy work around is to do a PageExtension for a given page and trap trigger OnQueryClosePage and then call an event subscriber codeunit procedure to set it up. It would then available to the codeunit when the OnQueryClosePage is subscribed.
A cleaner and simpler solution is to expose the CloseAction in the integration event OnQueryClosePageEvent. Then a subscriber codeunit could directly determine whether or not its code should run.
STATUS DETAILS
Needs Votes

Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team