Check Dirty Fields or Forms in Dynamics 365

 In Dynamics 365, sometimes there is requirement to check if field value/form is changed or not. In that case we can use getIsDirty Client API reference which will return value true if field or form value is changed.

Syntax:
formContext.data.entitygetIsDirty();   //Form is dirty
formContext.data.entity.attributes.get(arg).getIsDirty();  //field is Dirty

To get the list of attributes that have been modified in this session, you can check the IsDirty of the attribute : 

getListOfDirtyAttributesOnForm: function(executionContext) {
    var formContext = executionContext.getFormContext();
    var AccountAttribute = formContext.data.entity.attributes.get();
    if (AccountAttribute != null) {
        for (var i in AccountAttribute) {
            if (AccountAttribute[i].getIsDirty()) {
                listOfAttributes += AccountAttribute[0].getName() + ", ";
            }
        }
    }
}

Comments

Popular posts from this blog

Accessing Fields on QuickView Form through javaScript

ADF - (Part 2) Integrate Data From CRM to External system

ADF - (Part3) Integrate Data From CRM to External system Using Stored procedure