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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to mark form as being saved?

(0) ShareShare
ReportReport
Posted on by

In the Dynamics system that I'm working on, there is an entity with a custom form.  There is a special field on this custom form.  When it contains certain values, the Javascript code that handles the save event for the form cancels the default event with eventArgs.preventDefault() and instead executes a web service call.

That is all fine and well, except for one problem.  When the user sets the custom value and clicks [Save & Close], Dynamics shows a warning message in Javascript that the user's changes have not been saved. (You can only imagine how absurd it is to the end-user to click [Save & Close] and see such a warning!)

Apparently, this preventDefault() invocation seems to tell Dynamics not to save the form, which is fine because the form is saved by the web service call, but at the same time, since Dynamics thinks that that form hasn't been saved, it shows a warning message.

My goal here is to make Dynamics stop showing the warning message.

Simply removing the preventDefault() invocation seems to work, but sometimes results in the form being saved twice, which can be problematic and is entirely predictable.

My thought is that since I am invoking preventDefault() but still saving the form using a web service call, Dynamics needs to know not to show the warning message.  How do I do thisS?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Okay, I figured it out!

    Xrm.Page.data.setFormDirty(false);

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans