To check if user has changed a variable value in form via onChange script in portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:41 AM
Hi
Is there a way to know if the user has changed a field value in a catalog item.
I am using onChange catalog client script. On change of a variable in portal i need to know if the field was changed by user. For the context I am using API to autopopulate the same field but the field is still editable so the user can change the value. So i need to know when its modified by user. I have tried g_form.isUserModified function but it didn't work.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:48 AM
Hi Angelin,
Since you are using a Catalog Client Script, all you need to do is have your script trigger OnChange for the variable in question. From there, just compare the values in the newValue and oldValue variables that are created when the function fires.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:50 AM
Hello,
You can use the updated by and gs.getUserId(); and check if both are same then it will work.
you have to use UI policy script.
Regards,
Alok Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:52 AM
Hi,
oldValue and newValue should help you; but that would require onChange client script on each variable
You can use hidden text variable and populate in it the values which you are auto-populating in all the variables.
then in onSubmit you can compare the values against each variable against the value present in the hidden text variable
That would tell you which variables got changed as part of user input
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader