Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ejonesWhat ryeh is probably the fastest way of doing it. In the attached graph are two additional options.
The first is a "brute force" method that runs slower but by spreading the logic over more nodes the logic might be easier to follow. This "brute force" method usually works with reporting hierarchies since there is usually a clear limit as to how many levels the hierarchy will ever have. And, as is done with the "Meta Check" node, you can have the graph warn you if the number of levels is more than expected so you can go add support for an additional level.
The second uses a looping node and will go as deep as the data supports. One danger here is that if there is a loop in the reporting hierarchy the graph will never complete on its own until it slowly uses up all the disk space and fails, or you notice that it hasn't completed in a day or so and stop it. I suppose a way to check for an infinite loop during the run is to read all the accumulated data and looking for duplication where you have more than one record showing an employee reporting to the same manager. Adding this will slow the iterations down considerably but would make it more resilient.
Attachments:
ReportingHerarchyExample.brg