Hello
everyone, I guess the people working on CRM 2011, might have seen this error (a
pop up message) either once. Recently I was just going through my contacts within
CRM, I just opened the form and just closed it without changing anything,
suddenly out of nowhere this pop up message appeared on the screen.
Initially I over checked my form again & again if I had changed something on the form, later I checked if any script on the form is changing any field, still nothing. I was getting restless, I did not change a thing on the form, but still whenever I try to close the form, this message appeared on the screen.
Later I wrote a javascript function which will show any dirty fields on the form.
function FindDirty() {
var message = "The
following fields are dirty: \n";
Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
if (attribute.getIsDirty() == true) {
message += "\u2219 " +
attribute.getName() + "\n";
}
});
alert(message);
}
After I put up this script on load of the contact form, I reloaded the form and found that the parent customer id (a lookup field) was dirty
After much R & D I found that, the value of the primary attribute of the lookup (generally the name field) contained two consecutive spaces (due to a concatenation issue pre-import). Any time you have a record with 2 or more characters of white space in the name field, and that record is selected in a lookup, Microsoft CRM will think that lookup is dirty. The reason is because CRM tries to be clever around removing extra white space between words. What ends up happening is when it’s checking to see if a lookup is dirty, it checks to see if both the default value and the current value have the same id, typecode, and name. But when it checks the name part, the default value has the correct spacing, and the current value has the trimmed spacing, and so they don’t match and CRM thinks the lookup is dirty.
Later when
I opened my account form, I saw that the name contained more than single
consecutive spaces.
After I removed these spaces and saved the account. Then when I opened my contact, and tried closing without change, it closed normally as it should without any message.
Hope this helps someone who has faced this weird issue !!!
After I removed these spaces and saved the account. Then when I opened my contact, and tried closing without change, it closed normally as it should without any message.
Hope this helps someone who has faced this weird issue !!!
Thanks for
taking time to read my blog J