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
Hi Vaish03,
Take a look at this article for dirty field operations: https://carldesouza.com/checking-isdirty-dynamics-365-using-javascript/
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:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148