Dynamics 365 – How to Trigger OnChange Event of an Attribute

fireOnChange() function is used to trigger the registered onChange events of an attribute. It is also very useful when you update an attribute through Javascript Code and it onChange event doesn’t trigger.

When you update an attribute from Javascript code, its onChange event doesn’t trigger. If you want it to be triggered, you have to use fireOnChange()

FireOnChangeTest: function (executionContext) {
var formContext = executionContext.getFormContext();
// You first update the value of the "myAttribute"
// Then You want to trigger onChange event of the "myAttribute".
formContext.getAttribute("myAttribute").setValue(newValue);
formContext.getAttribute('myAttribute').fireOnChange();
}
view raw FireOnChange.js hosted with ❤ by GitHub

One thought on “Dynamics 365 – How to Trigger OnChange Event of an Attribute

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 )

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