web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

AL code OnQueryClosePage Exit without Saving

(1) ShareShare
ReportReport
Posted on by 3,255
Hi All
Is there a way to use OnQueryClosePage where a use can exit the record without saving. Say you are editing a record and a mandatory field is not filled in . at this point use has 2 choices, enter the mandatory field or exist record without any changes
 
    trigger OnQueryClosePage(CloseAction: Action): Boolean
    begin
        // Check only when closing with OK or LookupOK actions
        IF CloseAction IN [ACTION::OK, ACTION::LookupOK] THEN BEGIN
            // Validate that Dimension is not empty
            if Rec.Feild1 = '' then
                Error('must have a value');
        END;
    end;
I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    95,763 Super User 2025 Season 2 on at
    There is no way to completely block users using this trigger, because users can also simply close the browser. . . .
    So I don't recommend this approach. You can add controls when using this data. For example, if this is an item, control it when the user selects the item.
     
     
    Hope this can give you some hints.
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans