Redirect approval to users manager if user goes inactive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 07:03 AM
Hi All,
I am writing a Business rule (after/update) if any user goes inactive then it script will assign approval records to users manager.
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord('sysapproval_approver');
gr.addEncodedQuery('state=requested^approver.sys_id=',+current.sys_id);
gr.query();
while(gr.next())
{
gr.approver=current.manager;
gr.update();
}
})(current, previous);
but this script is not working. Kindly suggest
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 07:21 AM
Your script may have a synytax error somewhere but what about a different approach...
I think the problem is if the approval has already been sent- it has to be approved from that exact user or else it wont work unless the Manager is a Delegate. - You could make a Business rule that when a user is marked inactive- then their manager is set as a delegate instead - So in the conditions- Active marked as false- then create a new Delegate record and plug in the values for the user and their manager. and check Approvals box.
So a request comes in where User A will be an approver
User A before they get a chance to approve is marked inactive- the script will make their manager the delegate - the manager can now approve under MY approvals
IF the user is marked inactive before the workflow reaches user A- the manager will get the email
If it is after they will have to go in and approve under MY PENDING APPROVALS- but this is simular to unnassigning tickets from an ex employee you may clear or process their pending approvals