CRM 2011 – Form is always dirty – Check fields.

With CRM 2011, whenever you want to automatically refresh or save a form that has supposedly not been modified by a user, and still get that annoying “Are you sure you want to leave” message, you can sometimes start getting a bit upset about it. Xrm.Page.data.entity.getIsDirty() always returns true.

I need to find the fields that are dirty. I put the following code on FormLoad method :

attribute[] attributes = XrmWrapper.Page.data.entity.attributes.get();
foreach (attribute i in attributes)
{

if (i.getIsDirty())
{
Script.Alert("attribute dirty: " + i.getName());
}
}

In this way I have the name of all attributes on the form that they are in Dirty status.

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...