How to use onUserchangeValue(function fn) { } ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2020 12:58 AM
Hi ,
Please can you give me the scenario for the use of this script:
onUserChangeValue(Function fn) this function how to use and where
var handler = function(fieldname, originalValue, newValue) {
console.log('The field ('+ fieldname + ') has a new value of: ' + newValue); // function code
}
var unregister = g_form.OnUserChangeValue(handler);
// To unregister the event listener
unregister();
Please help me .
waiting for your response .
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2020 05:23 AM
This is triggered when a user makes a change on a form.
So in onUserChangeValue(Function fn) - the "Function fn" portion is, in the code above, the handler function.
The handler function passes in 3 values, the field name, the old value and the new value. The return of the function, so the console log, is then passed into the g_form.OnUserChangeVaule() and is unregistered.
Basically the use of this is to log changes to a form from a user. Stating the field name and the new value.
Changes from client scripts, UI policies, or any other non-user interactions, do not trigger the listener. On a user changing a value on a form can trigger this.
Please mark helpful or correct depending on the impact of my response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2021 05:16 AM
Hi Shelby,
Where shall we define this function? This function need to be defined in a UI Script or client script or as an event or etc..to recognize the changes done to a form?