- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 11:04 PM
Hi experts,
We have below requirement.
When ever a manager opens 'XYZ record producer' on portal, Requested for variable should display their reportees and If these reportees are managers, their reportees should also be displayed.
Ex. If manager 'A' has 3 reportees ( Say P,Q,R) and if P has 3 reportees (say X,Y,Z)
A should see P,Q,R as well as X,Y,Z
How can we achieve this.
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 06:38 AM
Hi @si21
Please try with below Script Include :
var GetReportees = Class.create();
GetReportees.prototype = {
initialize: function() {},
getAssociates: function(user) {
var reportees = [];
var userGr = new GlideRecord('sys_user');
userGr.addQuery('manager.sys_id', user);
userGr.query();
while (userGr.next()) {
reportees.push(userGr.sys_id.toString());
var userSysID = userGr.sys_id.toString().trim();
var managerGr = new GlideRecord('sys_user');
managerGr.addQuery('manager',userSysID);
managerGr.query();
var rowCount = managerGr.getRowCount();
if (rowCount != '0') {
while(managerGr.next()); {
reportees.push(managerGr.sys_id.toString());
}
}
}
return 'sys_idIN'+reportees;
},
type: 'GetReportees'
};
Thanks & Regards
Amit Verma
Amit Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:59 AM
@vermaamit16 Thanks a lot for quick response. It's working fine now.
