Catalog Client Scripts, are they limted to variable set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 02:01 PM
I have two variable sets. One has variables A and B, and the other has variables C and D.
If I want to set variables C and D from data captured in variables A and B, would a catalog client script that is on the variable set for C and D have access to A and B on the different set?
Or does A, B, C, and D have to be part of the same variable set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 02:45 PM
Hi there,
I create an example based on your question:
There are 2 variable set "Variale Set A" and "Variable Set B"
In the varible set A contain variable (var_a), for the variable set B (var_b).
The variable inside these variable set can be access to each other, if you create a catalog client script.
I've create on onChange Catalog Client Script to copy the value of B and set it to A (in the Variable name field you've to choose the Variable Set that need to be capture to another one).
Please try this approach, put some alert if you need to see the value of the field.
Regards,
Huy Lam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:57 PM - edited 07-17-2023 11:02 PM
Thanks for your help, just one problem: I want the variable set B to populate data from A when A is changed.
The onChange client script only assumes if B is changed. The logic I need is that when A is changed, B is populated with data from A.
However, because I do not own Variable Set A (I am not allowed to modify that update set to add my catalog script), the client script must be run from Variable Set B. Can this be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 11:08 PM
if you want to do some processing on C OR D when A or B changes then 2 ways
1) create onChange catalog client script which Applies to your Catalog Item and select the type as onChange and select the variable A or B
OR
2) create onChange catalog client script which Applies to your variable set and select the correct variable
Since you told you don't own the variable set then you better go with option 1 as the script will run only for your catalog item
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
07-18-2023 07:39 AM
I'm quite sure you can't do this oob. Catalog Client Scripts that are within a variable set are limited to the scope of that variable set. You may be able to get around this with an advanced ajax glide script from within the variable set's Catalog Client Script...but you'll be relying on data that already exists on the server (ajax doesn't work with client session data).