Listing all users who report to the current user

nathandanek
Tera Contributor

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! 

5 REPLIES 5

It tells them that they do not have any direct reports, but in reality this VA topic will only be available to managers, which all have direct reports. So it is unlikely anyone will ever get to this point.