Identify “Dirty” fields on Microsoft Dynamics CRM form

By | December 28, 2015

Introduction:

There may be times when you want to identify the fields that have been modified by the user in the current update.

While one way and the most common way has been to create a Plugin, the plugin only receives data of the fields that have been modified in the current update. If you wanted to check the previous value, you could compare the PreImage with the current value in the target and if they don’t match, it has been modified.

What if we had to identify the modified field through scripting?

It is common knowledge the form provides an IsDirty property that can be used to check if the form has been modified. We can check the form IsDirty using

To get the list of attributes that have been modified in this session, you can check the IsDirty of the attribute. Here is a sample code of how you can loop through all the attributes and get the list of the modified attributes on the form

Another function that comes in handy here is
var dataXml = Xrm.Page.data.entity.getDataXml();

the result would be

Identify Dirty fields on Microsoft Dynamics CRM form

Using the above function you can get a list of the data that is passed to the platform on update, and this inturn lists all the attributes that have been modified along with the current values being sent to the platform.

Conclusion:

Combination of getIsDirty on the form/attribute and getDataXml would help you quickly build a tracking tool without the need for a plugin.

Now do Accounting inside your Dynamics CRM, with InoLink  – MS Dynamics CRM & Quickbooks Integration

Leave a Reply