Managers to see their direct reports and other manager direct reportes under specific conditions

Ashmiya
Tera Contributor

We have requirement on a specific HR Service 

where if a field 'request type' is 'employee spot award' -->  managers must be able to see his direct reports and other manager direct reports in the field 'employee name'

whereas if field 'request type' is anything other than  'employee spot award' ---> Managers should only be able to see their direct reports only in the field 'employee name'

 

Kindly help me how to configure these in our instance?

 

1 REPLY 1

suvro
Mega Sage
Mega Sage

Reference qualifier should be advanced and a script include will be required: reference qualifier should be like this

 

javascript: 'sys_idIN' + new scriptInclude().methodName(current.variables.request_type);

 

In the script include you can write the below script

var users = [];

var emp = new GlideRecord('sys_user');

emp.addActiveQuery();

emp.addQuery('manager', gs.getUserID());

emp.query();

 

while (emp.next()){

users.push(emp.getUniqueValue()); 

if (requestType != 'Employee spot award'){

return users;

}

 

var empM = new GlideRecord('sys_user');

empM.addActiveQuery();

empM.addQuery('manager', emp.getUniqueValue());

empM.query();

 

while (empM.next()){

 

users.push(empM.getUniqueValue());

}

}

return users;