- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2020 08:50 PM
The approver of the RITM is no longer with the company, so the user is locked out and the approval of few RITMs is pending for approval. He was the Owner of two Parent Groups in the system.
I have manually changed the new Group Owner of the mentioned Parent groups. But how can I write a script to change the approver of the pending RITM of that Parent Group with the new Group Owner which I changed just now.
Provided I dont know the exact RITMs pending with the locked out user.
PS. I am new to ServiceNow and I am trying to write code on my own to figure this out. Any help will be great. Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 04:56 PM
Off the top of my head this should work. Please test it in a sub prod instance first.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('approver', 'sys_id');//replace the word sys_id with the sys_id of the user who holds the approvals.
gr.addQuery('state', 'requested'); //Only bring back pending approvals
gr.query();
while (gr.next()){
gr.approver = 'sys_id of new approver'; //this will need to be the sys_id for the new approver.
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2023 07:28 AM
Can I see your modified script? I don't see why this would cause the workflow to cancel as you are not modifying the workflow just the approval records.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2023 08:33 AM - edited 02-07-2023 08:40 AM
Hi Brian,
Thanks for getting back to me on this topic.
Here is the script :
var m = new GlideRecord('sysapproval_approver');
m.get('01f3fc62872319506a7f63560cbb353a');
m.approver = '5da8a83cff86ac008fea114e40b9ad40';
m.update();
However, I executed on a dev instance and noticed that the modification was successful and did not corrupt or erase the workflow in place in the RITM.
This specific behavior in our instance is most probably caused by custom business rules or specificities related to our context.
So I confirm that your script is working fine.
Best regards