“When I use the Power Automate approval action and set it to ‘Approve/Reject – First to Respond’ i still get the ‘Apply to each’ automatically created when i use the output.”
“I have a Power Automate flow that sends an approval request to a single user. When I try to use the output of the Approval (for example the comments they have added) in a subsequent step, ‘Apply to each’ container is added.”
Output of the approval task in Power Automate is always an array of responses. And like every other array in Power Automate, if you want to access the data, you must loop through it. Process each of the objects in the array, one by one, using the ‘Apply to each’ action. It doesn’t matter how many objects the array contains. It can be just one response or 10 responses, important is the returned data type, and that’s an array. But using expressions, there’re other ways to access objects in an array.
If it’s an array with only a single object, you can use the first() expression. You input an array as the parameter and it’ll return the first object from that array. And your responses array has only a single object, the first one.
The easiest way to get the array parameter is to actually let the flow add the ‘Apply to each’. It’s the same input, you can take it from there.
e.g. first response from 'Start and wait for an approval' action: first(outputs('Start_and_wait_for_an_approval')?['body/responses'])
Now you have the first response, but the response is an object with multiple values. It contains all information from the response: approver name, response, comments… Therefore, you must extend the previous expression by adding the desired value.
As before, you can get the value when you use the dynamic content in the flow. It’s the part beginning with the ? that you should add.
e.g. display name of the approver from the first response: first(outputs('Start_and_wait_for_an_approval')?['body/responses'])?['responder/displayName']
You’ll need the expression for each value from the response you want to use, no more dynamic contents. The difference when building approval history is shown on the screenshots below. Using dynamic content inside ‘Apply to each’:
Using first() expression to avoid ‘Apply to each’:
I’d say avoiding the ‘Apply to each’ action is often a cosmetic topic in Power Automate approval processes. You can use the first() expression instead, but then the response processing part of the flow will be full of expressions, making the flow harder to read and understand.
Using ‘Apply to each’ is +1 loop in the flow. Using the first() expression is -1 loop, but +X expressions. You must decide which approach makes more sense to you.