cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

List of all direct reports and subordinates

I'm trying to build a Power Automate flow that will output a list of all every user that reports (both directly and indirectly) to a manager user ID (input).  I have tried to use the "Office 365 Users.Get direct reports" action, save the output to an array variable, and then loop through that array with the same "Get direct reports" action to return the next layer of users.  When finished, I would append all these lists together for a single complete list of all direct and indirect reports.

 

My issue is there could be 5+ layers of management in the organization, so I would like the flow to keep digging into each user until the "Get direct reports" returns nothing.  There has to be a simpler method than essentially an infinite number of embedded loops!

24 REPLIES 24

@antonyclark, everything you should need will be included in the two posts marked as the accepted solutions.  If you have issues, I will do my best to help troubleshoot.  

Super, I'll be having  crack at this later this evening or tomorrow.

 

Thanks for you help man.

@JimSutt - Thanks for sharing the flow. Can you please help me with the code for "Length" field in the JSON step

Hi @RohitD , the length statement is as follows:

 

length(variables('FinalArray'))

 

This statement returns the number of rows in the array.  The Do Until loop will continually run until the counter catches up to the the number of rows in the array, indicating that there are no new rows.  

Hoping someone can help me, I followed the screenshots but am getting an error of "resource / user not found: in the direct reports v2 step ? It looks like it's finding the the email from JSON string? 

 

 

{
  "error": {
    "code": "ResourceNotFound",
    "message": "User not found",
    "innerError": {

 

 



Also, it looks like by default the do until runs 60 times. We have 200+ employees under our VP so I'm not sure what to put in the limit under advance settings in do until. thoughts? 

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (7,050)