Bulk changes to change ticket owners

thirteen

var changes = ["CHG0005983"];
new_owner = 'nm64';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

twelve

var changes = ["CHG0005981","CHG0005982"];
new_owner = 'kad36';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

eleven

var changes = ["CHG0005980"];
new_owner = 'ap349';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

ten

var changes = ["CHG0005978","CHG0005979","CHG0005986"];
new_owner = 'vl24';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

nine

var changes = ["CHG0005977","CHG0005987","CHG0005988"];
new_owner = 'ww236';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

eight

var changes = ["CHG0006362"];
new_owner = 'emt2';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

seven

var changes = ["CHG0006308"];
new_owner = 'mrd25';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

six

var changes = ["CHG0006272"];
new_owner = 'jv278';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

five

var changes = ["CHG0006270"];
new_owner = 'owen';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

four

var changes = ["CHG0006257"];
new_owner = 'aw479';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

three

var changes = ["CHG0006222"];
//new_owner = 'lrj28';
// should actually be david hirsch
new_owner = 'dah36';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

two

var changes = ["CHG0006180"];
new_owner = 'susan';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

The other ones are not as easy

var changes = ["CHG0006155"];
new_owner = 'sd452';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

This worked for the tickets from David Swanson

var changes = ["CHG0005974","CHG0005976","CHG0005988"];
new_owner = 'ds292';

for (i=0; i<changes.length; i++) {
    var gr = new GlideRecord('change_request');
    gr.addQuery('number',changes[i]);
    gr.query();
    if(gr.next()) {
        gs.print("owner = " + gr.assigned_to);
        gr.assigned_to = new_owner;
        gr.update();
    }
}

this hunk didn't work, but there might be something of value here

var oldOwner='db692-admin';
var newOwner='ds292';

// set groupName to the group where you want to synchronize team leads to be the same
// as the set of all members of the group
// this is especially useful for CTS STC groups
var gr1 = new GlideRecord('change_request');
var tickets = [];
gr1.addQuery('assigned_to.netid',oldOwner);
gr1.addQuery('short_description','CONTAINS','r12:');
gr1.query();

while ( gr1.next() ) {
 gs.log("ticket owned by " + oldOwner + ": " + gr1.number);

 var gr2 = new GlideRecord('change_request');
 gr2.addQuery('number',gr1.number);
 gr2.query();
 gr2.next();
 gr2.assigned_to.netid=newOwner;
 gr2.update();
}