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

Announcements

No record found.

News and Announcements icon
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)
  • Community Member Profile Picture
    on at

    Hi ShivAgrawal,

    Could you share code you have written and screenshots?

  • ShivAgrawal Profile Picture
    10 on at

    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

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    Write below code before you refresh your form from javascript

    formContext.data.entity.save();

  • ShivAgrawal Profile Picture
    10 on at

    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,985 Moderator on at

    Hi,

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

    docs.microsoft.com/.../getdataxml

  • ShivAgrawal Profile Picture
    10 on at

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 172

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans