Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Revert a boolean value to its original value when user chooses 'No' on confirm dialog

Posted on by 10

I need to revert a value on a page to what it was at the time the page was opened if the user clicks 'No' on the confirmation dialog.

This is what I have now.

OnOpenPage()
ActiveStatus := Active;
CloseStatus := Close;

...

OnQueryClosePage(CloseAction : Action None) : Boolean
ReviewPeriod.GET(Code);
PhaseNo := Name;

IF Close <> CloseStatus THEN BEGIN
ConfirmChanges := ConfirmMsg;
Answer := DIALOG.CONFIRM(ConfirmChanges, TRUE, PhaseNo);

IF Answer THEN
EXIT;
IF NOT Answer THEN BEGIN
Rec.Close := CloseStatus;
EXIT;
END;
END;

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,171 Super User 2024 Season 2 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    Hi, What happens if you close the current page and reopen it in your code? I tested in Card Page, this works.

    https://yzhums.com/16756/

    pastedimage1678929823028v1.png

    Hope this helps

    Thanks.

    ZHU

  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 45 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    Updated:

    Check if property RefreshOnActivate is on for ListPage

  • Jesse Otu Profile Picture
    Jesse Otu 10 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    NorthW That's not really necessary because that field is exclusive to that page. So, unless changes are made in the development environment, it should be fine.

  • Jesse Otu Profile Picture
    Jesse Otu 10 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    Thanks raibilalhaider . It works but the changes are made on a card page and do not reflect on the corresponding list page unless I refresh it. Any suggestions?

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    I think you also should look into doing this in the OnValidate trigger on the table instead of in the page.

    What if your data it modified outside of this one page?

  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 45 on at
    RE: Revert a boolean value to its original value when user chooses 'No' on confirm dialog

    Hi,

    I think you just need to call Rec.MODIFY before EXIT in last third line. Rest of code look fine.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans