Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Unable to Add Existing Catalog Variable Sets to a New Catalog Item

terrieb
Tera Guru

Trying to add 3 variable sets to a new catalog item and getting the messages below:

terrieb_0-1762348873533.pngterrieb_1-1762348885513.png

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!

2 ACCEPTED SOLUTIONS

@terrieb 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

@terrieb 

I believe you should mark that response as correct which has script so that it helps other members in future.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@terrieb 

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 the internal name of a Variable Set is exactly same as the name of the variable inside it, the va... 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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. 

@terrieb 

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

AnkurBawiskar_0-1762351736405.png

 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@terrieb 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader