Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Dynamics 365 discard changes from javascript

(0) ShareShare
ReportReport
Posted on by 10

Hi All,

I have implemented a dialog box in dynamics 365 crm which appears based on some business condition when user saves the form. In the dialog box i have given user only one option to refresh the form and everything is working fine until here as designed.

But as soon as the user hits on the refresh button the system shows and unsaved change dialog box which have two options "save and continue" and "discard". If the user hits on discard my form is refreshed but if user hits on the save and continue option then the refresh dialog box will again pop-up and it will continue ti be in the same loop until the user clicks on discard option.

I want to give the user ability to discard the changes and refresh the form when they hit on the refresh options in the dialog box and so they won't have to make a choice between save and continue or discard. They can directly click on refresh button to discard the changes and refresh the page so they get the latest changes.

I want to implement this discard and refresh code in javascript. So, kindly help me out with this if there is any possible way to perform this.

Thanks in advance!!

Regards,

Shiv

  • ShivAgrawal Profile Picture
    ShivAgrawal 10 on at
    RE: Dynamics 365 discard changes from javascript

    This is only giving me options to get the list of dirty field and it doesn't allow my changes to get discarded.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Dynamics 365 discard changes from javascript

    Hi,

    You can use below client api to get list of dirty field

    docs.microsoft.com/.../getdataxml

  • ShivAgrawal Profile Picture
    ShivAgrawal 10 on at
    RE: Dynamics 365 discard changes from javascript

    I don't want to save the unsaved data, i want to discard the changes and then refresh the form. I don't have the code to discard all unsaved data.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Dynamics 365 discard changes from javascript

    Hi,

    Write below code before you refresh your form from javascript

    formContext.data.entity.save();

  • ShivAgrawal Profile Picture
    ShivAgrawal 10 on at
    RE: Dynamics 365 discard changes from javascript

    For some reason i cannot share the code with you. I just want the ability to discard unsaved changes and refresh the form. so i don't see the unsaved changes dialog box.

    pastedimage1662163323572v1.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamics 365 discard changes from javascript

    Hi ShivAgrawal,

    Could you share code you have written and screenshots?

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,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans