Get the top manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2016 08:17 AM
Hello, while working on a workflow, I need to get the approbation from the top manager who is in the XYZ group of the user for whom the item is requested for.
My script can only check if the manager and the manager's manager are in the XYZ group.
How can I make my script more dynamic to get the Nth top manager ?
var answer =[];
var manag = current.variables.requested_for.manager;
var supmanag = current.variables.requested_for.manager.manager;
function getManager(){
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', manag.sys_id);
gr.addQuery('group', 'XYZ_sys_id');
gr.query();
if(gr.next()){
answer.push(manag.toString());
}
}
function getManagerMan(){
var gr1 = new GlideRecord('sys_user_grmember');
gr1.addQuery('user', supmanag.sys_id);
gr1.addQuery('group', 'XYZ_sys_id');
gr1.query();
if(gr1.next()){
answer.push(supmanag.toString());
}
}
if(!manag.isNil())
{
if(!supmanag.isNil()){
getManagerMan();
}
else{
getManager();
}
}
else if(manag.isNil())
{
answer.push('sysadmin_id');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2018 03:43 AM
I need to check the below hierarchy for current user in service-now.
I can check this hierarchy but unfortunate if any some put any of the any low-level person is manager of another top-level user it’s leading to a loop
Ex: In the below image
If any user by mistakenly put L4 Person is manager of l2 the system going to loop between the L2 and L4 User
Please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2018 03:44 AM
I need to check the below hierarchy for current user in service-now.
I can check this hierarchy but unfortunate if any some put any of the any low-level person is manager of another top-level user it’s leading to a loop
Ex: In the below image
If any user by mistakenly put L4 Person is manager of l2 the system going to loop between the L2 and L4 User
Please help me on this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2018 06:46 AM
I'm not clear what your objective is. Can you give an example of what is working or not, and how you would like it to with sample data?