Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Update all the catalog items with new User Criteria

dev_K
Tera Contributor

Hi All,

 

Is there a way to add additional user criteria to all the catalog items? I find it that modifying this property for +400 catalog items would be to mundane. Any way to do it faster all at once?

5 REPLIES 5

Dr Atul - LNG
Tera Patron

HI @dev_K 

 

There is no related list (M2M) which can be used to update all item in one go. You need to do manual way only. 

****************************************************************************************
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************

Sandeep Rajput
Tera Patron

@dev_K You can write a fix/background script to update the user criteria on the desired catalog items by making entries in sc_cat_item_user_criteria_mtom table. 

Ankur Bawiskar
Tera Patron

@dev_K 

you can use background script for this and handle it

Something like this

var catItemSysId = 'sysId1,sysId2'; // give the 400 sysIds here as comma separated values
var arr = catItemSysId.split(',');
var userCriteriaSysId = ''; // give the sysId of the User Criteria here

for (var i in arr) {
    var rec = new GlideRecord('sc_cat_item_user_criteria_mtom');
    rec.initialize();
    rec.sc_cat_item = arr[i];
    rec.user_criteria = userCriteriaSysId;
    rec.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@dev_K 

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

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