- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 04:36 AM
Hello,
We have two catalog items that use the same variable set. We would like to make one of the individual variables inactive in one of the items but keep it active in the other item. Is this at all possible?
Thanks in advance
David
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 04:46 AM
Hi @davidsmith
Yes, managing variable visibility and activity for specific catalog items in ServiceNow, even when they share the same variable set, can be achieved using a more dynamic approach since variables within a shared variable set will, by default, have the same properties (like active/inactive status) across all catalog items that utilize that set. Here’s how you can approach this:
### 1. Catalog Client Scripts
One of the most effective ways to control the visibility and activity status of variables for specific catalog items is through Catalog Client Scripts. You can write a client-side script to conditionally hide or show variables based on the catalog item being viewed.
#### Example:
Suppose you have a variable named example_variable in a shared variable set, and you only want it to be active (visible) in Catalog Item A and not in Catalog Item B. You’d do something like this in a Catalog Client Script:
function onLoad() {
// Assuming ‘sys_id’ is the unique identifier of the item
// Replace ‘catalog_item_a_sys_id’ with the actual sys_id of Catalog Item A
var itemAId = ‘catalog_item_a_sys_id’;
if (g_form.getUniqueValue() === itemAId) {
// Show the variable for Catalog Item A
g_form.setDisplay(‘example_variable’, true);
} else {
// Hide the variable for other items (e.g., Catalog Item B)
g_form.setDisplay(‘example_variable’, false);
}
}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 04:46 AM
Hi @davidsmith
Yes, managing variable visibility and activity for specific catalog items in ServiceNow, even when they share the same variable set, can be achieved using a more dynamic approach since variables within a shared variable set will, by default, have the same properties (like active/inactive status) across all catalog items that utilize that set. Here’s how you can approach this:
### 1. Catalog Client Scripts
One of the most effective ways to control the visibility and activity status of variables for specific catalog items is through Catalog Client Scripts. You can write a client-side script to conditionally hide or show variables based on the catalog item being viewed.
#### Example:
Suppose you have a variable named example_variable in a shared variable set, and you only want it to be active (visible) in Catalog Item A and not in Catalog Item B. You’d do something like this in a Catalog Client Script:
function onLoad() {
// Assuming ‘sys_id’ is the unique identifier of the item
// Replace ‘catalog_item_a_sys_id’ with the actual sys_id of Catalog Item A
var itemAId = ‘catalog_item_a_sys_id’;
if (g_form.getUniqueValue() === itemAId) {
// Show the variable for Catalog Item A
g_form.setDisplay(‘example_variable’, true);
} else {
// Hide the variable for other items (e.g., Catalog Item B)
g_form.setDisplay(‘example_variable’, false);
}
}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 06:44 AM
Dear @Deepak Shaerma
Thank you so much for your help. I will look into using a catalog script.
Kind regards
David