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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 166 Super User 2026 Season 1
Jimmy Passeti 51 Most Valuable Professional
NeerajPawar 51