JScript – what changed on this form?

Every now and then, if your scripts are performing form changes, and you try to navigate without saving, you will be prompted to save. But what if you want to see exactly what was changed on a large form?

The following function can show you the modified fields:

function checkIsDirty()
{
    var _mesage = "";
    Xrm.Page.data.entity.attributes.forEach(
        function(attribute, index)
        {
            if(attribute.getIsDirty() == true)
            {
                message += attribute.getName() + "\n";
            }
        }
    );
    alert("These fields have been modified: \n" + message);
}

You could put this on a ribbon button, and allow the form user to check at any time what was changed since the last save. Alternatively, you could highlight the fields with a different background color rather than bring up an alert message.

Enjoy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: