CRM 2011 Checking for changed fields in a form

Sometimes, when trying to close a form down in Dynamics, or trying to print preview, you will often get the following message.

isDirty

This will nearly always mean that when the form has loaded, some of the attributes have actually changed, so Dynamics detects that the form is not up to date, and requires a save before proceeding.

This can sometimes be tricky to work out what has changed, so below is a useful little trick.

In Internet Explorer, hit the F12 key when the form is displayed, and select the script tag.  Copy and paste the following code in to the script input area and run it.  This should then print out the name of all of your “Dirty” fields.

var listOfAttributes = frames[0].Xrm.Page.getAttribute();
for(var attrib in listOfAttributes){
   var currentAttrib = listOfAttributes[attrib];
   if (currentAttrib.getIsDirty && currentAttrib.getIsDirty()){
     console.log(currentAttrib.getName());
   }
}

Leave a Reply