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

Community site session details

Session Id :
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

I have the same question (0)
  • ShivAgrawal Profile Picture
    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
    28,981 Moderator 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
    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
    28,981 Moderator 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
    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
    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

Quick Links

Responsible AI policies

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

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
DAnny3211 Profile Picture

DAnny3211 251

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 137 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 90 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans