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?
Solved! Go to Solution.
Hi @Anonymous
you can try the following:
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.
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.
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.
Hi @Anonymous
you can try the following:
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.
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.
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.
This worked great. Thank you for the solution.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
70 | |
24 | |
18 | |
16 | |
13 |
User | Count |
---|---|
134 | |
43 | |
32 | |
32 | |
29 |