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 and term...
Power Automate
Unanswered

Apply to Each and terminate

(2) ShareShare
ReportReport
Posted on by

Hi,

 

I have a Flow that gets triggered when a SalesForce record is modified and then updates the same record in a SharePoint list.

The Flow works by getting all the list items (SharePoint - Get Items) and matching the list record number with the record number of the modified SalesForce record. The flow works fine but takes 1h to run.

 

I have 7000 unique items in the SharePoint list and I would like the flow to stop after it has found the one item that needs to updated. Right now I have initialized a variable to 0 which gets set to 1 when the list item is updated - when the variable is 0 the flow stops doing anything but it still has to go through the rest of the list items. I tried putting the Apply to Each inside a Do Until but it didn't work: the do until only "looped through" one instance since the Get Items returns one instance - or so it seemed.

 

Is there any way to terminate the Flow inside the Apply to Each... control terminate isn't allowed inside an Apply to Each 😞

 

Heres a picture of the flow:

flow.PNG

 

 

 

 

 

 

Regards,

T

Categories:
I have the same question (0)
  • vecerpa Profile Picture
    786 on at

    Hi @Anonymous,

     

    Right now there is no simple way to exit apply to each.

    There is already added Idea in Flow forum, so please vote for it - https://powerusers.microsoft.com/t5/Flow-Ideas/Exit-from-quot-Apply-to-Each-quot/idi-p/30760#M1733.

     

    But I was just thinking how to better update SharePoint list item and not to go throught whole list. I know that each item have specific ID generated by SharePoint. So my ID is to somwhere inside salesforce, possible programatically, store such ID for furhter usage inside SharePoint list. You will have easier way and of course faster to update ShP list. It can be somewhere in comments of such item.

    P.

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @vecerpa,

     

    Yes, SharePoint generates a unique ID as well, the problem is I don't know which item has what ID, thats why I can't use Get Item instead of Get Items. In addtion, I have no way of matching any salesForce field to my Sharepoint ID.

     

    To get rid of the unnecessary looping of 7k items, I tried adding a filter query to my Get Items ( Number eq 'Opportunity Number') but I get an error that column Number doesn't exist...

     

    Regards,

    T

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Anonymous- You mention in your post that you have 7000 ittems that you want to loop through with a for each loop.  You should be aware that the Flow documentation indicates that there is a hard limit of 5000 iterations for a for each loop.

     

    Scott

     

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @ScottShearer,

     

    My flow loops through them - I'd prefer that it didn't. I'd want it to loop until it finds a match or then filter Get Items before it loops.

     

    Heres an example of a succesful flow:

    It seems that it does loop through 7k items...

    applytoeach.PNG

     

     

     

     

     

     

     

     

     

     

    Regards,

    T

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @AnonymousVery interesting...

     

    I just tried to configure Get Items to retrieve over 5000 items in order to run a test of Apply to Each, but I got an error when I tried to save the Flow saying that I can't set it above 5K.  I know that I was able to do so within the past few days.   If I don't turn on pagination, it will save for me but it reverts back to 100 item max.

     

    I wonder if changes are being made to this functionality that are slowly being rolled out.

     

    MaxCount.jpg

  • Community Power Platform Member Profile Picture
    on at

    @ScottShearer

     

    Interesting indeed..I agree, this might be because of changes in the functionality.

     

    My flow has been active for the last 4 days and I haven't had an error with the item amount.

    My pagination is on and I've set the limit to 15000:

     

    pagination.PNG

     

     

     

     

     

     

     

    One thing that might somehow have an effect is the fact that my coworker originally created the flow until the get items part and he set the limit to 15k.

    I also tried creating my own new flow and I'm still able to set the limit to 15K.

     

  • ChrisKoenig Profile Picture
    Microsoft Employee on at

    The 5K limit is applied to CDS, not necessarily to other data sources. Excel, for example, has a limit of 250 rows when you read it from OneDrive...

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard