Catalog Client Script in a Variable Set: setReadOnly not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 12:58 PM
I'm trying to use a Catalog Client Script to set Read Only to a bunch of variables in a variable set. Others are having setReadOnly set to false as I expect data to be populated on these variables. This variable set is on a Record Producer, and the script is only being run on the Target Record.
However, when I attempt to use g_fom.setReadOnly (<variable_name>, true) or g_form.setReadOnly (<variable_name>, false), neither of these options work. And before you wonder why I'm using a Catalog Client Script instead of a Catalog UI policy, it's because I'm using a g_scratchpad variable to determine the course of action.
Is it possible that setReadOnly doesn't work on Catalog Client Scripts on variable sets?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 12:15 PM - edited 02-18-2025 12:19 PM
I will clarify as to what's happening.
This variable set is attached to a Record Producer. It is only set to be enabled when the target of the Record Producer (in this instance, a Workplace Case) is loaded. By default the variables in the Variable set are hidden.
The catalog client script has two objectives: to unhide the fields in the variable set, and (depending on the value of the scratchpad variable, make some fields read only and others editable. Here is an excerpt of the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:01 PM
if you are using display business to store scratchpad variable and trying to use that in catalog client script, then I believe scratchpad variable doesn't work in catalog client script
But only in normal client script.
Move your business rule logic to GlideAjax and use in catalog client script and use script include
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
02-18-2025 05:42 AM
I can confirm the scratchpad variable is working. It's gathering data as it should and it's going into the correct piece of code. What is NOT working is the setReadOnly function.