Dynamics CRM: get all updated fields in javascript

By | November 29, 2012

I got somewhat strange form behaviour in Dynamics CRM this morning – for whatever reason, at attempt to close one of the phone call records kept brining up a “do you want to save the updates?” dialog. It did not seem to matter that there were no updates, and, even once all the javascripts have been removed, this strange behaviour went on.

I figured that I may need to see which field is causing this, so, here is a javascript code snippet which does this job – if you run into a similar situation, just add a web resource with this code, and, then, add a call to showDirtyAttributes to the “onSave” event of your form:

function showDirtyAttributes()
{
var names = “”;
Xrm.Page.data.entity.attributes.forEach(function(attribute, index)
{
if(attribute.getIsDirty())
{
names += attribute.getName()+”;”;
}
});
alert(names);
}

It actually helped – to some extent. It turned out one of the lookup fields did not like the reference assigned to it for some reason. It did work, I could navigate from that field to the referenced record.. However, I had to update that referenced record and choose it for the lookup once again to finally get rid of the “do you want to save the updates?” dialog.  I’m still wondering what was so unique about that record, though..

Leave a Reply

Your email address will not be published. Required fields are marked *