cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kind
Frequent Visitor

Start and wait for approval from a dynamic list of users

 I have a flow which reads from a list of dynamic users (ranges between 1 to 10 users) and sends an email to approve a new or updated document. Once all users approve the new or updated file, the status (metadata column in SharePoint library) is set to approved.

 

Part 1 of flowPart 1 of flow

 

Part 2 of flow where i get the errorPart 2 of flow where i get the error

 

However I am getting the error below:

3.PNG

 

I managed to get this flow work for a static amount of predefined users, however when I read from the list of dynamic users, an "Apply for each" loop is created, and I don't know how to access the result of all users inorder to approve or reject the file.

3 ACCEPTED SOLUTIONS

Accepted Solutions
JohnAageAnderse
Memorable Member
Memorable Member

Hello @Kind 

 

The Approvals actions already provides you with an option to request a response from all the people that you add to the Approval action.

First you take all your approvers and collect their email addresses into an array variable.

Then you add the email addresses from the array variable into the Assigned to field using an expression "join(variables('name of your variable'),';') - this will join all email addresses as a string with semicolon between each.

 

The Approval action now waits for all to approve or reject. If all approve, the outcome is Approve. If one or more reject, the outcome is Reject.

Each approvers response can be seen in the Responses collection in the Approval action.

 

Hope this helps you on the way. Kind regards, John

View solution in original post

Hello @Kind 

You are nearly there I think 🙂

In the loop, use the Append to array action, not the Set variable action.

I assume that the column Approvers is a people column with multiple people, correct?

If not, how is it defined?

Kind regards, John

 

View solution in original post

Hello @Kind 

Good that you now have the email addresses in the array variable.

After that, you should only have the Approval action (not in the loop) and in the Assigned to field use an expression:

join(variables('ListOfApprovers',';')

 

That will add all the approvers email addresses to the Assigned to field! And your approval action will not end up inside a loop 🙂

Kind regards, John

View solution in original post

8 REPLIES 8
JohnAageAnderse
Memorable Member
Memorable Member

Hello @Kind 

 

The Approvals actions already provides you with an option to request a response from all the people that you add to the Approval action.

First you take all your approvers and collect their email addresses into an array variable.

Then you add the email addresses from the array variable into the Assigned to field using an expression "join(variables('name of your variable'),';') - this will join all email addresses as a string with semicolon between each.

 

The Approval action now waits for all to approve or reject. If all approve, the outcome is Approve. If one or more reject, the outcome is Reject.

Each approvers response can be seen in the Responses collection in the Approval action.

 

Hope this helps you on the way. Kind regards, John

Thanks for your reply John.

 

I tried your solution but I couldn't access the email. Maybe because I am very new to Power Automate. I Just started using it.

 

This is what I tried

 

4.PNG5.PNG

Hello @Kind 

You are nearly there I think 🙂

In the loop, use the Append to array action, not the Set variable action.

I assume that the column Approvers is a people column with multiple people, correct?

If not, how is it defined?

Kind regards, John

 

Thanks, I updated to "append to array" and found the email address. However now I got the same error again as my first post.

 

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2852': 'The template language expression 'body('Start_and_wait_for_an_approval')?['outcome']' cannot be evaluated because property 'outcome' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

 

This is my current flow:

 

Part 1Part 1part 2part 2ErrorError

Hello @Kind 

Good that you now have the email addresses in the array variable.

After that, you should only have the Approval action (not in the loop) and in the Assigned to field use an expression:

join(variables('ListOfApprovers',';')

 

That will add all the approvers email addresses to the Assigned to field! And your approval action will not end up inside a loop 🙂

Kind regards, John

@JohnAageAnderse  Thanks for your great help.

 

Hopefully I have one final error, maybe you can still help me get there.

 

ErrorErrorMy FlowMy Flow

 

My error

 

InvalidTemplate. Unable to process template language expressions in action 'Start_and_wait_for_an_approval' inputs at line '1' and column '2887': 'The template language function 'variables' must have only one parameter.'.

Kind
Frequent Visitor

@JohnAageAnderse  I managed to get it to work.

 

Thanks for your great help.

 

11.PNG

dmclaughlin
Post Patron
Post Patron

I'm also trying to get the start and wait to work sending email to field that has multiple emails.  Did you get it to work?  Can you attach print screens?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (2,300)