in script include how to get the list of users for whom the logged in user is manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 07:29 AM
A is manager of B and B is manager of C.
then C should be able to see the B and A list.
and B should only see the A list.
how to get that list...in script include i want...because i am going to apply it as a dynamic filter to achieve it in report
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 07:46 AM
I'm confused between your question title and description. I am C - I have a manager (who has a manager), but I am not anyone's manager. So if I (C) am the logged in user, I should see all of the users with my manager, and my manager's manager (B & A)? And if my manager (B) is the logged in user, he should see a list of users with his manager (A)? And there's only 3 levels here, so A does not have a manager, or at least not that is relevant to this situation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 07:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 08:11 AM
That sounds like the opposite of the A, B, C explanation, but see if this fits your requirement
var userArr =[];
var usr = new GlideRecord('sys_user');
usr.addQuery('manager',gs.getUserID());
usr.query();
while(usr.next()){
userArr.push(usr.getValue('sys_id'));
var usr2 = new GlideRecord('sys_user');
usr2.addQuery('manager', usr.sys_id);
usr2.query();
while(usr2.next()){
userArr.push(usr2.getValue('sys_id'));
}
}
return 'sys_idIN' + userArr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 07:47 AM
Hi Pravallika,
Please try below code.
var users =[];
var gr_user = new GlideRecord('sys_user');
gr_user.addQuery('manager',gs.getUserID());
gr_user.query();
while(gr_user.next())
{
users.push(gr_user.getValue('sys_id'));
}
return 'sys_idIN'+users;
Please mark helpful and correct, if it's applicable for you.
Regards,
Vinay