Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

AL code OnQueryClosePage Exit without Saving

(1) ShareShare
ReportReport
Posted on by 2,437
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;
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,813 Super User 2024 Season 2 on at
    AL code OnQueryClosePage Exit without Saving
    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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,296 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,285 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans