Import sets and Transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:45 AM
Hey ServiceNow Gurus,
I have imported a catalog item through excel sheet (using Import sets and Transform map), I then imported Variable sets followed by Variables into their respective tables using same method, then I had to add the variable set in the catalog item manually. everything worked perfectly fine.
Now that I want to Import Variable set such that I don't have to add it manually to the catalog item. after importing variable set it must be directly appearing in the variable sets of catalog item.
Note : Variable set form has Related list "Included in", which maybe the way to work.
any help is highly appreciated.
Regards,
Ubada Barmawar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 08:05 AM - edited 02-19-2024 08:05 AM
You might need to do an import in io_set_item which has variable set and catalog item mappings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 08:11 AM
I dont wanna perform any additional import, I just want a script that provides the solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 08:14 AM
Hi,
U can first import the variable set and then when u import the variables, in variable there will be a fields called catalog item and variable set, map those fields with respective catalog item and variable set. So that it will automatically map them.
If my answer is correct, please mark it as Helpful. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 08:19 AM
Hi @Ubada Barmawar,
To achieve the automatic association of Variable Sets with Catalog Items during import in ServiceNow, you can leverage Business Rules. Here's a script example that you can use as an "after insert" Business Rule on the Variable Set table:
```javascript
// Business Rule script on Variable Set table (after insert)
(function executeRule(current, previous /*null when async*/) {
// Check if the Variable Set is being created for a specific Catalog Item
var catalogItemId = current.catalog_item.toString();
if (catalogItemId) {
// Get the Catalog Item record
var catalogItem = new GlideRecord('sc_cat_item');
if (catalogItem.get(catalogItemId)) {
// Add the Variable Set to the "Variable Sets" related list of the Catalog Item
var includedIn = new GlideRecord('cmdb_ci_incident');
includedIn.initialize();
includedIn.setValue('child', catalogItemId);
includedIn.setValue('parent', current.sys_id.toString());
includedIn.insert();
gs.info("Variable Set added to the Catalog Item: " + catalogItem.name);
} else {
gs.error("Catalog Item not found with ID: " + catalogItemId);
}
}
})(current, previous);
```
Please note:
1. This script assumes that there is a reference field called `catalog_item` on the Variable Set table, linking to the Catalog Item. If it is named differently, then use appropriate field name.
2. The `cmdb_ci_incident` table is used in the "Included In" related list, but you should replace it with the correct relationship table used in your instance.
Make sure to adapt the script according to the actual field names and relationships in your ServiceNow instance. Additionally, thoroughly test the script in a non-production environment before deploying it in a live instance.
Regards,
Ehab Pilloor