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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / "Apply to each" infini...
Power Automate
Unanswered

"Apply to each" infinite looping in Power Automate?

(0) ShareShare
ReportReport
Posted on by 64

I have just started using Power Automate with Powerapps, and I'm trying to create a flow to check on an user list what users have admin privileges, so I can send them an email to approve or not a new user registration.

Before trying to sent the email, I'm trying to check if my flow will find correctly the users with admin privileges, so I have set a condition to make the check and "Create Item", which create an item at the same list with the value 1 if there is an admin user (YES property), and with the value 0 if the conditions doesn't match (NO property).

 

gasilva8_3-1636644133051.png

 

I get stuck on this part of the flow, because I don't understand what is going on.

Before running the flow, the list bellow had 14 items. The 1st and 8th items correspond to users with admin privileges. As you can see, the flow created new item with 1 for the 1st and 8th, as expected, since 1st and 8th users are admins.

The problem is that after that, it continues creating items with 0s (it created almost 100 items!!).

 

gasilva8_4-1636644240321.png

 

Any tips to work around that?

Since I gonna send approval email, I really would like to understand why that occurs to avoid sending a lot of emails to some admin user.

 

Categories:
I have the same question (0)
  • Verified answer
    Barret Profile Picture
    652 Most Valuable Professional on at

    It looks like you've set up circular logic. When you iterate through a list, you can't add items to the same list you are iterating through. If you do, it will then iterate through the items you added because they are a part of the list now. So if you have a list of 10 items, and 3 of those items create new items on the list, when you get to item 10, your list is now 13 items long and it will continue with items 11, 12 & 13, all three of which may also add items depending on your logic. So then, when you get to 13, it's now 16 elements long and it goes on to items 14, 15 & 16, and on and on. 

     

    Your output should create items in a new list. And then, after the Apply to Each loop, if you want those new items in the original list, merge the two lists together. But only after the Apply to Each loop.

  • gasilva8 Profile Picture
    64 on at

    Thank you @barret!

     

    I added a parallel branch and that solved my problem.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard