I'm creating a flow that would send a notification to users based on timeframes that I've set up in individual variables - however, to test that, I have to run through the entire flow. Therein lies the problem.
The flow is pulling data from a SharePoint Online List, users are being used from two different columns and used as email recipients of the notification messages. However, each time I add the dynamic content, P.A. creates a new "For Each" loop and nests my "Send an Email" action within that action.
See below:
This is the Branch I am currently working on
Here is where I added the first recipient email address and Power Automate automatically added "Apply to Each"
Added the second recipient email address and the second "Apply to Each" action was automatically added which will cause the flow to error out.
This is the error I get when I run the Test:
That's pretty much the extent of the flow, calculate 15, 45, 90 and Expiration Date of the given column and send an email to those recipients - if I can only get over this hump of my email addresses not splitting up in "Apply to Each" actions. If anyone has any experience with this, I would be greatly appreciative! Thanks!
What causes Power Automate to wrap your action in Apply to Each is that your Person or Group field is set up in a way that multiple users can be selected. So Power Automate readies your flow to handle multiple values.
The other issue is that in many cases you only have one value in those fields so at runtime Power Automate is facing a single Person object instead of an array of Person objects.
Here's what you can do:
Now you have a single string value with all the email addresses so you can send a single email in the end with all recipients in the 'To' field. This article clarifies the Select/Join part.