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

Approval workflow - apply to each

I'm looking to build a flow using the approval workflow, sequentially moving from 1st approver, 2nd, 3rd up to 5th. 

 

I only have one approver at each step, the approval flow waits for the approver to respond, it then sends an email to the requestor with the approvers comments, and updates the sharepoint item with both the approver outcome and comments. 

 

However, because the approval workflow has 'responses comments' and not ' response comments' it treats this as an array and gives me the 'apply to each' grouping. This causes my flow to break once it gets further down the chain, as there is a limit to how many 'apply to each' options you can have. 

 

Flow.JPG

 

Has anyone come up with a way to just capture the individuals response comment so that it doesn't apply the 'apply to each' array grouping? 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

You can use first() to get the first record in the responses collection and then get the comments or whatever field you need from the collection.  Type the following into the Expression bar.

first(body('Start_and_wait_for_an_approval')?['responses'])?['comments']


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Gristy
Resident Rockstar
Resident Rockstar

Hi,

You can use the following expression:

 

body('Start_and_wait_for_an_approval')?['responses'][0]?['comments']
Pstork1
Dual Super User III
Dual Super User III

You can use first() to get the first record in the responses collection and then get the comments or whatever field you need from the collection.  Type the following into the Expression bar.

first(body('Start_and_wait_for_an_approval')?['responses'])?['comments']


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Thank you @Pstork1 , your solution worked perfectly

Hello! @Pstork1 This is really close to what I need, but I have five instances where I start and wait for an approval. Using your expression, I get the first one (as the expressions dictates). How would I write it to get comments submitted by all 5 approvers (sending all 5 comments in an email in #6)? Also, how would I write it for each branch? Meaning the approval request for #3 could see #1 and #2 comments and the approval request for #5 could see #1 and # 4 comments. Image is here: https://www.dropbox.com/s/xz00e941lh3qfaj/Flow%20Annotation.png?dl=0

I actually figured it out! I learned to code HTML in the 90s, LOL, so sometimes my reading of the code is rusty, but I got what I needed by updating the expression portion; ('Start_and_wait_for_an_approval') to the custom name of each of my approvals. So; ('Start_and_wait_for_Inst2') gets me the comments from Intsructor 2! I was able to do that for each of the 5 people who approve and comment in this flow. Woot! 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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