web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Active Discussion

Different methods of OnChange

(0) ShareShare
ReportReport
Posted on by 5

Hi All,

There are three methods you can use to work with the OnChange event for an attribute.

Could you please explain the below different methods, if possible please provide the Scenario based code.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You provided the urls for methods - that is great. If you will check the description at the top - it should be clear enough how every of method can be used:

    addOnChange - Sets a function to be called when the OnChange event occurs.

    example:

    function onNameChanged(executionContext){

    alert("name was changed");

    }

    //attach this function to onload event of the for and check "Pass execution context as a first parameter" checkbox

    function onLoad(executionContext){

    var formContext = executionContext.getFormContext();

    formContext.getAttribute("name").addOnChange(onNameChanged);

    }

    What this code does is following - during the load of the form code attaches onNameChanged function as a handle for onchange event of "name" field on the for.

    removeOnChange - Removes a function from the OnChange event hander for an attribute.

    it does opposite to the addOnChange - removes the handler from field. Example:

    function someFunction(executionContext){

    var formContext = executionContext.getFormContext();

    formContext.getAttribute("name").removeOnChange(onNameChanged);

    }

    fireOnChange - Causes the OnChange event to occur on the attribute so that any script associated to that event can execute.

    if you want to trigger event handler for the field when field value changes - you can use this method. Example:

    function someFunction(executionContext){

    var formContext = executionContext.getFormContext();

    formContext.getAttribute("name").fireOnChange();

    }

  • CRM Naren Profile Picture
    5 on at

    Hi Andrew,

    Greetings for the day!

    Thanks for your information.

    I saw some code snippet for the addonchange and Fireonchange functions can I consider the below as examples.

    pastedimage1593179888538v1.pngpastedimage1593179903007v2.pngpastedimage1593179913152v3.png

    Regards,

    Naren

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Naren,

    That could be considered as examples.

  • CRM Naren Profile Picture
    5 on at

    Thank you so Much for the information Andrew

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    You are welcome! If my reply answered your question take a minute and click "Yes" under the question "Did this answer your question?".

  • CRM Naren Profile Picture
    5 on at

    Yes

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 196 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans