Fix script for multiple updates

Kanna12
Tera Expert

Hello All,

 

I want to replace the new manager name in approval table. There are 400 rows that i need to replece the manager name.

How to right fix script to replece the values in table?

3 REPLIES 3

Akash4
Kilo Sage

Hi Sarsija,

Make sure to write the Fix script in right scope. Here is sample code you can start with and edit accordingly:

 

(function() {
var gr = new GlideRecord('sysapproval_approver');

gr.addQuery('manager', 'old_manager_sys_id'); // add old sysId
gr.query();

while (gr.next()) {
gr.manager = 'new_manager_sys_id';//add your sysid
gr.update(); 
}
gs.info('Updated manager names in ' + gr.getRowCount() + ' records.');
})();

 

Ravi Gaurav
Giga Sage

Hi @Kanna12 

First of all "sysapproval_approver" table doesn't have the manager field . so the above code won't work 

The field is "Approver" and you need to change it as per your manager sys_id.

var approvalRecords = new GlideRecord('sysapproval_approver');
approvalRecords.addQuery('approver', 'prviousMangerSys_id'); // Replace with the sys_id of the old manager
approvalRecords.query();

while (approvalRecords.next()) {
approvalRecords.approver = 'your new manager sys_id'; // Replace with the sys_id of the new manager
approvalRecords.update();
}

 

 

we are maining the approval group seperatley and calling that table in workflow when ever approval needed.