Reputation: 3297
On my function I'm checking if there are any changes on the page, and if there are I'm saving them.
However, even after saving Xrm.Page.data.entity.getIsDirty()
is still true
:
var isPageDirty = Xrm.Page.data.entity.getIsDirty(); //true
if (isPageDirty) { //Save if there were any changes
Xrm.Page.data.entity.save();
}
isPageDirty = Xrm.Page.data.entity.getIsDirty(); //still true!
Why is this happening? Shouldn't isPageDirty
change to false
after saving?
Upvotes: 2
Views: 2515
Reputation: 548
The shortest way to tell which fields are dirty is to alert the entity data xml i.e.
alert(Xrm.Page.data.entity.getDataXml())
Upvotes: 2
Reputation: 32713
There could be some other piece of script setting a value on that form. You can check what field/fields are causing this - by simply looping through the attributes, for example:
function showDirtyAttributes(){
var names = "";
Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
if (attribute.getIsDirty()) {
names += attribute.getName() + ";";
}
});
alert(names);
}
Taken from here
Upvotes: 3