Notifications
Announcements
No record found.
I'm trying to clear the dirty fields in Microsoft Dynamics CRM using a script, but I haven't been able to find a solution for it.
can anyone please advise on how I can clear the dirty fields in CRM using a script?
Thank You
Can you explain what "clear the dirty field" means?
If you want to set the dirty field value to null, then you can use this code:
function clearDirtyFieldValue(executionContext) { var formContext = executionContext.getFormContext(); var myField = formContext.getAttribute("SomeField").getValue(); // if the field is dirty, clear it if (myField.getIsDirty()) { myField.setValue(null); } }
If you want to control whether data from the dirty field will be submitted when the record is saved, then you can use this code:
function ignoreDirtyField(executionContext) { var formContext = executionContext.getFormContext(); var myField = formContext.getAttribute("SomeField").getValue(); if (myField.getIsDirty()) { myField.setSubmitMode("never"); } }
reference:
getIsDirty
setSubmitMode
Hi Vaish03,
Take a look at this article for dirty field operations: https://carldesouza.com/checking-isdirty-dynamics-365-using-javascript/
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 108 Super User 2025 Season 2
Jimmy Passeti 50 Most Valuable Professional
Gerardo RenterÃa Ga... 49 Most Valuable Professional