- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2015 02:05 PM
I'm trying to create a dynamic filter that will return the entire reporting hierarchy of the current user by looking at the manager field on sys_user. So far, I've gotten it to pull the direct reports of the current user but I've not been able to get the direct report's of the current user's direct reports. I would like to go six levels deep using something like this:
Current User -> Current User's Direct Reports -> Current User's Direct Report's Direct Reports
I thnk I need to use a while loop but I'm not quite sure how to do that. Any thoughts? Thanks!
Here's the script I have so far:
var getWithinMyReportingHierarchy = Class.create();
getWithinMyReportingHierarchy.prototype = {
initialize: function() {
},
getWithinMyReportingHierarchy:function(){
var u = gs.getUserID();
var gp = [];
var g = new GlideRecord("sys_user");
g.addQuery("manager", u);
g.query();
while( g.next()) {
gp.push(g.sys_id.toString());
}
return gp;
//
},
type: 'getWithinMyReportingHierarchy'
};
Solved! Go to Solution.