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

Get the highest level manager for a user

Hello, 

 

I am trying to build a flow that returns the highest level manager, who is a level below the CEO in any given department. 

 

For example, person A reports to person B, who reports to person C who reports to person D, who reports to the CEO. I need the flow to return the name of person D. E.g. a marketing intern reporting to a marketing manager who reports to a senior manager who reports to the vp of marketing who reports to the chief marketing officer who reports to the CEO would return the chief marketing officer. 

 

How can I use the GetManager and Do Until features to achieve this? 

1 ACCEPTED SOLUTION

Accepted Solutions
MarvinBangert
Solution Sage
Solution Sage

Hi @PN4567890 

you can try the following:

Image 662.png

My trigger is a "manually trigger a flow" with an email as an input. Then I create two variables, "varMail" is the first value the Email input from my trigger and array is empty.

Image 663.png

On the do until I set the condition to my CEO (I hope that you only have one final email/CEO that you can also use as a filter, otherwise you would need to check for maybe Position or something, where you find the CEO value). In my test environment "Albert Einstein" is my CEO. The "Get Manager" UPN is my variable "varMail" which i reset on every run with a new mail from the manager I found. Using the function "iterationIndexes('Do_until')" I can get the index of the current run and save it in an compose (or you can also use a variable).

Last I add the mail to an array, which I will filter later.

Image 664.png

When your flow exits the do until, the current index is the index of your CEO, so you need to subtract the index of your CEO by 1 to get the level below. You use this function "add(outputs('Compose_2'),-1)" in your action "compose". The last action "compose 3" give you the value from the array using the index from your "Compose" action that we calculated: variables('varArray')?[outputs('Compose')].

That should be your mail address from the manager under CEO. 

 

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

View solution in original post

2 REPLIES 2
MarvinBangert
Solution Sage
Solution Sage

Hi @PN4567890 

you can try the following:

Image 662.png

My trigger is a "manually trigger a flow" with an email as an input. Then I create two variables, "varMail" is the first value the Email input from my trigger and array is empty.

Image 663.png

On the do until I set the condition to my CEO (I hope that you only have one final email/CEO that you can also use as a filter, otherwise you would need to check for maybe Position or something, where you find the CEO value). In my test environment "Albert Einstein" is my CEO. The "Get Manager" UPN is my variable "varMail" which i reset on every run with a new mail from the manager I found. Using the function "iterationIndexes('Do_until')" I can get the index of the current run and save it in an compose (or you can also use a variable).

Last I add the mail to an array, which I will filter later.

Image 664.png

When your flow exits the do until, the current index is the index of your CEO, so you need to subtract the index of your CEO by 1 to get the level below. You use this function "add(outputs('Compose_2'),-1)" in your action "compose". The last action "compose 3" give you the value from the array using the index from your "Compose" action that we calculated: variables('varArray')?[outputs('Compose')].

That should be your mail address from the manager under CEO. 

 

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

View solution in original post

PN4567890
Helper II
Helper II

This worked great. Thank you for the solution.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,691)