Listing all users who report to the current user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 01:06 PM
Hello all,
I am attempting to use the dynamic choice input in the virtual agent and I want it to present the user using the virtual agent a list of all of their direct reports using the sys_user table and matching the 'manager' field with the current users name. This is the script I have written, but when I impersonate someone with direct reports (I am one of them), it tells me that they do not have any direct reports.
(function execute(table) { var options = []; var emp = new GlideRecord(table); emp.addActiveQuery(); emp.addQuery('manager',gs.getUserName()); emp.query(); while(emp.next()){ options.push(emp.getUniqueValue()); } return options; })(table)
Any help would be appreciated! Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 01:51 PM
var options = [];
var emp = new GlideRecord('sys_user');
emp.addActiveQuery();
emp.addQuery('manager',gs.getUserID());
emp.query();
while(emp.next()){
options.push(emp.getUniqueValue());
}
I changed this line of code " emp.addQuery('manager',gs.getUserID());". Try to add yourself as manager for two users and test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 02:14 PM
I have tried it this way and, unfortunately, it still did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 02:16 PM
I forgot this line, please add it and check
return options;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 01:54 PM
Hi @nathandanek ,
So what is expected when some one doesn't have any direct report.
-Thanks
Ashish
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution