- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13 hours ago
Good day!
I created a catalog client script that hide fields if the requested for is member of a group and selected specific request type. It works on the portal, but an issue encountered while changing the requested for field. Can someone know how to configure or fix the script for this? Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
You’re using an onChange client script on the request_type variable.
function onChange() { var deptId = g_form.getValue('requested_for_entity'); var requestType = g_form.getDisplayValue('request_type'); ... }This script only runs when request_type changes.
But when you change Requested for, the script doesn’t automatically re-run, so the visibility rules for your fields don’t update.
Fix :Create another onChange Client Script for the variable requested for.
Inside that script, call the same logic you already have (e.g., put your hide/show logic into a reusable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
it's onLoad or onChange script.
Please share some screenshots and the actual script and config screenshots of that client script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
Hi, this is the screenshot of the client script. It is an onChange script.
 
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
your onChange syntax needs to be updated.
if you are changing requested for variable and want same behavior then you should write 1 more onChange catalog client script and it will be for requested_for_entity variable and exact same code.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
Okay, I will try it. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12 hours ago
Hello, I have tried your proposed solution, but it still does not take effect.
Here is the result: