Check if any field on a D365 CE/CRM form is dirty

This function will return an array of fields which are currently modified by not saved on a form in Dynamics 365 CE/CRM

function CheckDirtyFieldsOnForm(executionContext)
{
    formContext = executionContext.getFormContext();
    var attributes = formContext.data.entity.attributes.get();
    var dirtyAttributes = [];
    if (attributes != null) {
        for (var i in attributes) {
            if (attributes[i].getIsDirty()) {
                dirtyAttributes.push(attributes[i].getName());
            }
        }
    }
    return dirtyAttributes;
}
Filed under: Blog

No comment yet, add your voice below!


Add a Comment

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

Comment *
Name *
Email *
Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.