web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Duplicate "Apply To Ea...
Power Automate
Answered

Duplicate "Apply To Each" inserted?

(0) ShareShare
ReportReport
Posted on by 373

Hi,

 

The short description of my intended flow is;

 

1. Get rows from Dataverse table which meet specified criteria (using List Rows)

2. For each row returned;

2a. Lookup the user's email address (using Search for Users V2)

2b. Send an email (using Outlook Send an Email V2) with the To parameter set to the output of step 2a

 

When I create the flow and get to step 2a, a "For Each" or "Apply to Each" is inserted before the "Search for Users" step. I understand why that is.

 

I can then do step 2b, and what I get looks like this;

 

Martin_W_0-1705942586002.png

Again, this makes sense to me. Logically, the first step gets a list of rows, and then for each row, it looks up the user to get the email address, then sends an email.

 

However, as soon as I set the "Send an Email" "To " parameter to use the "Search for Users" Email parameter, it inserts another "Apply to Each" or "For Each" like this;

 

Martin_W_1-1705942761173.png

Firstly - why on earth does it do this as the second "For Each" seems redundant at best - at worst couldn't it send out multiple emails?

Categories:
I have the same question (0)
  • Verified answer
    creativeopinion Profile Picture
    10,508 Moderator on at

    @Martin_W The Search for Users (V2) action returns an array of users—even if it's a single user. The output is still an array. You need to use an expression to access the dynamic content from the Search for Users (V2) output to avoid looping through the array.

     

    Take a look a this YT Tutorial I recently uploaded: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow

    In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:

    1️⃣ Looping through a Single Item

    2️⃣ Creating Unnecessary Nested Loops

    3️⃣ Looping through an Unfiltered Array

    At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.

    I'll also cover:

     How to avoid the Apply to Each action with a single item array

     How to use the item() function to access dynamic content in an array

     How to prevent unnecessary nested Apply to Each action loops

     How to use the Select action

     How to convert an array to a string with the Select action

    How to use the Filter Query field

     How to count the number of items in an array

     How to use a condition control

     How to use the concurrency control

     How to set a top count

     How to use Compose actions for troubleshooting

     

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution .
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok
     
  • Martin_W Profile Picture
    373 on at

    Hi @creativeopinion 

     

    Thanks for the reply. I've checked out the YouTube video and that solution no longer seems to work? The error message I'm getting is 

     

    "Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The workflow action 'Compose' at line '1 and column '3783' references the action 'Search_for_users_(V2)' of type 'OpenApiConnection': only the actions of type 'foreach' are allowed to be referenced by 'repeatItems' or 'items' functions.'.'."

  • creativeopinion Profile Picture
    10,508 Moderator on at

    @Martin_W Can you please share a screenshot of your flow in edit mode (Classic Editor view please) and a screenshot of the error and which action you are receiving the error in? 

     

  • Martin_W Profile Picture
    373 on at

    Hi,

     

    I've managed to sort this now. It turns out that the new Power Automate designer is not very good!

     

    Thanks for your help!

     

    Martin

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard