List ALL employees who tree up to a Manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2022 11:55 AM
We are trying to create a Catalog Item where a Management-level person can fill out and select any employee who trees up to them (i.e. all their direct AND indirect reports).
For example, let's say that we have the following employee structure (an obviously simplified example that only shows one employee at each level):
Note that each employee listed is the manager of the employee listed just below them. So if Bernice Burt were the one filling out this Catalog Item, she should be able to select from ALL the employees listed below her, as Carrie Carson reports to her directly, and everyone under that reports to her indirectly.
We already do a scaled-down version of something like this, where we list a person's direct reports, and first two levels of indirect reports. We do that through a Script Includes, whose code looks like this:
If we used this on our example, it would return the first three employee under them, but not the 4th (Fran Frankel).
Now, we could keep building on to this Script Includes, to include "manger.manager.manager.manager", but the point is, we do not know how many levels down we might need to go to capture everyone (it could be 6 or 7). It is kind of an unknown target.
Has anyone come up with any clever, efficient ways of doing something like this? Or do we just need to keep adding "manager.manager.manager..." to our Script Includes to go as far as we think it might ever go?
It seems to me that there has to be a better way.
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2023 05:30 AM
what's the problem you're running into? the script include spits out a list of comma-separated sys ids for the direct reports so you'll need to set your filter or reference qualifier accordingly so it's searching "sys id" > "is one of" > new ManagerEmployees().getDirectReports();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2023 05:49 AM
I had originally replied back on January 6, 2022 that it was erroneously returning both active and inactive records, and wasn't sure why. When I didn't get any response to that, I abandoned the idea and moved on.