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;
}

Leave a comment

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

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