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 / Prevent apply to each ...
Power Automate
Unanswered

Prevent apply to each loop with SharePoint list and Azure DevOps

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

Forgive me, I know there are solutions on the site for this issue but I have attempted a few of them, but they dont seem to work as I would expect when applying them to my situation...or most likely I am not implmenting them correctly. 

 

The flow, image below, is meant to be working as a ticketing tool / recording tool within Azure dev ops and email communcations.

  1. An Email request comes in
  2. the email subject is checked against a list
    1. if the subject is not found on the list then a new AD work item is created
      1. Then a new entry of with the subject and the AD workitem ID is logged in a Sharepoint list
    2. If the subject is found on the list & it is not flagged as closed then it updates the workitem via the AD workitem ID
      1. the update for this section has been removed. 

 

My problem is that the call to SharePoint "get items" causes a loop and creats a new item for every current entry in the SharePoint list.

So my question is, how do I prevent the "apply to each" from running multiple times?

Thank you in advance!

 

 

FlowLoop.PNG

 

 

Categories:
  • RezaDorrani Profile Picture
    12,145 on at

    Hi @GoblinKingdom 

     

    Approach 1

    When querying using get items you can use odata queries to filter the results

    https://docs.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)

    Next you can check the count of the get items query to see if items are returned based on your condition(filter query)

    You can use the length expression to check the output 

    If length >0 then item found else not found

     

    Approach 2

    Next option would be in your for each loop you can set a variable value only when your condition is true

    then outside of the loop check the variable value

    if yes - then update

    if no - then create

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    You can't really prevent the loop because Get Items will return a collection of items even if there is only one item retrieved.  So you will have to have a loop.  To prevent creation of multiple items you'll need to use the loop to aggregate the data into variables so that you can use those variables to create one item after the loop exits.

  • GoblinKingdom Profile Picture
    Microsoft Employee on at

     @Pstork1 I have seen this solution on other similiar threads, but i cant seem to get it to work properly for mine. Would you mind going into more detail about how to implement your suggestion?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 335 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard