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.
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.
Yes
You are welcome! If my reply answered your question take a minute and click "Yes" under the question "Did this answer your question?".
Thank you so Much for the information Andrew
Naren,
That could be considered as examples.
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.
Regards,
Naren
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();
}
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,430
Most Valuable Professional
nmaenpaa
101,156