If we need to see an update set report for a user, and potentially “move” some updates from global to another update set, this script is a good start:
Here’s the code:
var user_id = "asdfasdf-test";
var gr = new GlideRecord('sys_update_xml');
gr.addQuery("sys_created_by", user_id);
gr.orderBy("sys_created_on");
gr.query();
while(gr.next()){
gs.debug("Update for update set: " + gr.getValue("sys_created_on") + " " + gr.update_set.getDisplayValue());
// Make updates to gr that are needed, e.g. if it's in Global "move" to another set...
}
gr;
var updateSet = new GlideRecord('sys_update_set');
updateSet.get('6d257828db0810102c071f83059619f9'); // User's new update set
var user = new GlideRecord('sys_user');
user.get('64ac802b1bc27b040e288480cd4bcb1c'); // User's record
// Copy all the update_xml records from Global udpate set to his new one.
var updateXml = new GlideRecord('sys_update_xml');
updateXml.addQuery('sys_created_by', user.getValue('user_name'));
updateXml.query();
while(updateXml.next()){
if(updateXml.getValue('update_set') == '6ff0cd97db312200bd7cdbf0ce9619c1'){
gs.debug("Updatexml: " + updateXml.getValue("sys_id") + " " + updateXml.update_set.getDisplayValue() + " " + updateXml.getValue('update_set'));
updateXml.setValue('update_set', updateSet.getValue('sys_id'));
updateXml.update();
}
}
updateXml;