Can any one explain me. What is OnUserChangeValue with some demo?

thana22dhana
Tera Contributor

Need a full detail and a basic demo for that g_form.onuserchangevalue.

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

Information from doc site explains it pretty good: Registers a custom event listener that detects when any field in the current form is modified by a user. https://docs.servicenow.com/bundle/newyork-application-development/page/app-store/dev_portal/API_ref...

View solution in original post

5 REPLIES 5

Joshua Prakash
Tera Expert

The g_form.onUserChangeValue method is a powerful way to monitor, track and validate changes on fields dynamically.

Here's a practical example: Imagine a scenario where you want to track changes and validate the latitude input or ensure that the end date is greater than the start date. You can achieve this effortlessly with a client-side script like this:

💡 What’s Happening Here?
We're using g_form.onUserChangeValue to monitor changes across fields.
If the latitude isn’t valid, we display an error message directly on the form.
We also ensure that the selected end date doesn’t precede the start date.

🔎 This approach is perfect for providing real-time feedback, reducing errors, and enhancing the user experience on forms! 💬