1

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 full Flow Full Flow

This is the Branch I am currently working on 15 Days Out Branch

Here is where I added the first recipient email address and Power Automate automatically added "Apply to Each" Added Lab Director Email

Added the second recipient email address and the second "Apply to Each" action was automatically added which will cause the flow to error out. Added Responsible Person Email

This is the error I get when I run the Test:

Test Error

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!

1
  • Could you try to add email as expression and not from the dynamic content tab? For example: items('Apply_to_each')?['Lab Director/Email'] Commented Jul 6, 2023 at 12:14

2 Answers 2

1

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:

  1. Initialize an array variable for all recipients.
  2. Use Apply to Each loops to iterate the Directors and Responsibles and Append to array variables inside to add them to the array variable. This makes sure that you have an array type even if there's only a single recipient.
  3. Use the Select action to reduce the Person objects to their email addresses.
  4. Use the Join action to concatenate all the email addresses. Use semicolon separator.

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Variables should be initialized once at the beginning of your flow. Don't nest this action in scopes or loops. Instead in your loop, use Set or Append to update your variable. Then, it will be available in the dropdown for the Send email action.
So I reworked my flow a bit to make it a little more concise, the issue I was having earlier was that I'll ultimately have to send an email out for each timeframe (15 days, 45 days..etc), you can see the updated flow here: updated flow However i am getting hung up on your step 2, I am not able to add in my new variable as it not selectable in my drop-down when I try to append to array. Only Available Options
0

to avoid that inside Apply to each to the group /person, the another answer is right, select , join to extract the email address.

But the best way to do is make it simple, in the sharepoint list, the email address to typed in by the user, that is the best choice.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.