
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 12:09 PM
if an approval user is inactive approvals should have to trigger for his manager instead of inactive user how to achieve this functionality. i want to achieve this functionality for global applications .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 09:16 PM
Hi Pavan,
You may use the below code to find the approver in the management hierarchy if the current user is inactive.
var approver;
var count = 0;
var user = new GlideRecord('sys_user');
user.get('62826bf03710200044e0bfc8bcbe5df1');
if(user.active)
approver = user;
else
approver = getApprover(user, count);
gs.log(approver.name);
function getApprover(user, count){
if(count > 10)
return;
if(user.active)
return user;
else
return getApprover(user.manager, ++count);
}
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 07:50 AM
Hi Pavan
I tried that already but no luck. Also it should be a Before Insert rule instead of before update, isn't it? Because it should check the user status before the approval record is created in the instance.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 05:11 AM
Never mind I have sorted it out. If anyone is looking for the same rule, please find the below.
Before Insert Business Rule
Table: sysapproval_approver
Script:
var appr = current.approver.sys_id;
//gs.log('The approver--> '+appr);
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', appr);
gr.addQuery('active', false);
gr.query();
if(gr.next()) {
var mgr = gr.manager;
current.approver = gr.manager;
//gs.log('The final manager--> '+mgr);
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2021 01:29 AM
Thanks for sharing your solution!
For Nitin BR use before BR with insert.