variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All
I just wanted to check. I have a variable set that is being used across multiple catalog items. I have a new requirement for a specific catalog item, where I need to add logic on the Requested For variable. How can I implement this logic without affecting the other catalog items that use the same variable set?
The requirement is to allow submission based on the user's manager. I tried creating another variable set, but it resulted in a duplicate Requested For field and caused additional issues. Could you please guide me on the best approach?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @bhanukota09 ,
You can keep using the existing variable set and add the validation only for the specific catalog item. There's no need to create a new variable set, as that will result in duplicate Requested For fields and can cause other issues.
A common approach is to add a Catalog Client Script (onSubmit) or Catalog UI Policy and condition the logic to run only for the required catalog item. If the requirement is to restrict submission based on the Requested For user's manager, you can perform the validation in an item-specific client script and, ideally, validate it server-side using GlideAjax for better security.
This way:
- The shared variable set remains unchanged.
- Other catalog items using the same variable set are not impacted.
- The manager-based validation is applied only to the targeted catalog item.
I would recommend implementing the validation through an item-specific onSubmit Catalog Client Script with a server-side check, rather than creating another variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @bhanukota09
- Navigate to specific Catalog Item >Catalog Client Scripts related list
- Set Applies to to A Catalog Item.
- Select your target Catalog item name.
- Set the script Type (onLoad, onChange, etc.) and write your conditional logic referencing the requested_for variable name.
Here the script is bound to the item rather than the variable set, it will only execute for that specific item.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
You can try the below approach:
Create the following only for the target catalog item:
- An item-specific Catalog Client Script on the existing requested_for variable.
- A client-callable Script Include to validate the manager relationship.
- An item-specific hidden variable to store the validation result.
- An item-specific onSubmit Catalog Client Script as the final submission check.
ServiceNow supports applying Catalog Client Scripts either to a variable set or directly to a catalog item. When the script is applied to a catalog item, it can still access named variables inherited from a variable set. Therefore, you can select the existing requested_for variable without changing the shared variable set.