Fix script for multiple updates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 09:35 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 10:14 PM
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.');
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 10:29 PM - edited 09-24-2024 10:31 PM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 07:30 AM
we are maining the approval group seperatley and calling that table in workflow when ever approval needed.