cancel
Showing results for 
Search instead for 
Did you mean: 
rampprakash

#4 How to check Dirty Fields in DataVerse/Model Driven Apps

What is mean by Dirty?

 

Consider Onload of Screen, sometimes we will get UNSAVED CHANGES, because we may Run some scripts in the OnLoad Operation, to find out which field gets modified we can use Dirty Operation to find the Respective Fields.

 

Implementation Steps:

 

1. Navigate to https://make.powerapps.com

2. Expand Dataverse

3. Expand Tables where you want to check DIRTY.

4. Click Forms --> Open main Form --> Add Event Handler in OnLoad Operation then Enter the Function name then paste below code in WebResource and Call checkFormIsDirty in OnLoad Operation

 

 

 

 

 

// Get the Dirty Fields in Alert
function CheckFormIsDirty(executionContext) {
var formContext = executionContext.getFormContext();
    attributes = formContext.data.entity.attributes.get();
    if (attributes != null) {
        for (var i in attributes) {
            if (attributes[i].getIsDirty()) {
                // Display the name and value of the attribute that has changed
                alert(attributes[i].getName());
            }
        }
    }
}

 

 

 

 

 

That's it.

 

If you are new to JAVASCRIPT. Please use this Link to learn the same and Subscribe to the Channel