Setting Variable set value to many catalog items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 04:24 PM
I have a situation where I have about 1100 catalog items that all need a single variable set added to them. Is there a way to do this in mass in the serviceNow portal?
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 12:34 AM
To add a catalog variable set to a large number of catalog items in ServiceNow, you can use the following methods:
1. Use a Catalog Item Update Script
You can use a script in ServiceNow to add the catalog variable set to all catalog items. For example, you can run a script like the one below in the Script Editor to add a catalog variable set to all catalog items.
Note: Make sure to test this script on a development instance and back up your data before running it.
2. Use Data Import Functionality
Prepare Data: Prepare a CSV file or other format containing the catalog item IDs and the catalog variable set information you want to add.
Data Import: Use System Import Sets > Load Data to import the CSV file and create an import set.
Transform Map: Create a Transform Map to define how the imported data should be transformed.
Script: Execute a script to add the catalog variable set to the catalog items based on the imported data and the Transform Map.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 12:47 AM - edited 08-04-2024 04:45 AM
Hi @joeycoleman
1. Create a single variable in a variable set.
2. Use background script to add the variable set to all 1100 catalog items.
Below is a sample script were i wanted to add a variable set to all active catalog items., in your case you can add a encoded query in place of active filter
var variableSetSysId = 'YOUR_VARIABLE_SET_SYS_ID';
var catalogItemGr = new GlideRecord('sc_cat_item');
catalogItemGr.addQuery('active', true); // replace with your encoded query of 1100 catalog items.
catalogItemGr.query();
while (catalogItemGr.next()) {
var catalogItemVariableSetGr = new GlideRecord('sc_cat_item_variable_set');
catalogItemVariableSetGr.initialize();
catalogItemVariableSetGr.setValue('cat_item', catalogItemGr.getSysId()); // Catalog Item sys_id
catalogItemVariableSetGr.setValue('variable_set', variableSetSysId); // Variable Set sys_id
catalogItemVariableSetGr.insert();
}
I hope this helps....
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 03:08 AM
Hi,
You can easily add all the needed catalog items to your variable set, without the need for any scripting, by navigating to the variable set (Service Catalog > Catalog Variables > Variable sets)
Open your specific variable set.
Open the "Included in" related list.
Press edit to open a slush bucket list edit, and move all the required Catalog items from the left side to the right side.
Done!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 03:56 AM
Nice one!
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field