- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Trying to add 3 variable sets to a new catalog item and getting the messages below:
I was able to add 5 other variable sets with no error messages and these 3 have the most variables listed within them (like over 50 total) so don't want to reproduce them if I don't have to!
Been able to do this action before - use variable sets alot - so not sure why this is happenning
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
I believe you should mark that response as correct which has script so that it helps other members in future.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
the error clearly says the name of variable is repeated and hence it's blocked
the only way is to make variable name is different
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have used the same variable sets in 3 other catalog items with no error message. There is no variable currently in the new catalog item with the same name. So I don't think that's the reason
Any other suggestions? I can't do a copy of the existing variable sets without losing all the variables contained within.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
your 3 catalog items have some variable with internal name as formatter and the same internal name is present for some variable within those 3 variable sets you are trying to add.
Did you searching that?
these OOTB BR might be restricting the insert operation
try adding those variable set using background script and use setWorkflow(false) during insert so that those BRs are skipped
// Define the sys_id of the variable set and catalog item
var variableSetSysId = 'variableSetSysId'; // Replace with the actual sys_id of your variable set
var catalogItemSysIdArr = ['sysId1', 'sysId2', 'sysId3']; // Replace with the actual sys_id of your catalog item
for (var i = 0; i < catalogItemSysIdArr.length; i++) {
// Create a new GlideRecord for the io_set_item table
var gr = new GlideRecord('io_set_item');
gr.initialize();
// Set the variable set and catalog item references
gr.variable_set = variableSetSysId;
gr.sc_cat_item = catalogItemSysIdArr[i];
gr.setWorkflow(false);
gr.insert();
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
if the above works fine, do remember to capture that newly created record into your update set using this updated script below
Ensure you are in correct update set while running this background script
// Define the sys_id of the variable set and catalog item
var variableSetSysId = 'variableSetSysId'; // Replace with the actual sys_id of your variable set
var catalogItemSysIdArr = ['sysId1', 'sysId2', 'sysId3']; // Replace with the actual sys_id of your catalog item
for (var i = 0; i < catalogItemSysIdArr.length; i++) {
// Create a new GlideRecord for the io_set_item table
var gr = new GlideRecord('io_set_item');
gr.initialize();
// Set the variable set and catalog item references
gr.variable_set = variableSetSysId;
gr.sc_cat_item = catalogItemSysIdArr[i];
gr.setWorkflow(false);
gr.insert();
var gum = new GlideUpdateManager2();
gum.saveRecord(gr);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
