- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 07:46 AM
There is a variable(business_unit_plant_name) inside one of my variable set(del_business_unit_plant_name) in my record producer so my ask is that that variable set should only come up on the form when the country(u_country) chosen from other variable of that record producer is germany and u_legal_entity is (DE01) and also that variable set should be mandatory.
As I will be using this variable set in too many record producers so how can I achieve this thing and that region and country variable is already there in all of those record producers coming up from different different variable sets.
now what I have done is that I have created a ui policy for that variable set that on load that would be visible false so how to now make that visible true as per my country and legal entity condition. I tried catalog client script but it was not happening or maybe my code was not correct.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 10:23 PM
you should use onLoad/onChange catalog client script which Applies to Variable Set and check in URL the sysId of record producer
If it's your record producer then run the logic, if not then do nothing
This will ensure your logic runs only on your record producer and not on other record producers where this variable set is used.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var url = top.location.href;
if (url.indexOf('recordProducerSysId') > -1) {
// your logic
}
}
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
06-25-2025 07:50 AM - edited 06-25-2025 07:53 AM
Hi @aditya2810,
In that case you should write a catalog client script applied on the catalog item the variable that IS NOT in that variable set (u_country).
Example (not tested) variable 1 is the depending variable and it shall be applied onChange with this variable
//update the condition properly
Try that and let me know how it goes.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 10:11 PM
I have 8 catalog items in which I need to use this variable set so I can not create 8 catalog client scripts to apply n each of the catalog . Is there any way possible to apply this directly on the variable set level ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 10:23 PM
I shared the working solution above, please check
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
06-25-2025 10:23 PM
you should use onLoad/onChange catalog client script which Applies to Variable Set and check in URL the sysId of record producer
If it's your record producer then run the logic, if not then do nothing
This will ensure your logic runs only on your record producer and not on other record producers where this variable set is used.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var url = top.location.href;
if (url.indexOf('recordProducerSysId') > -1) {
// your logic
}
}
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