Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Find record in array and break "apply to each"

(0) ShareShare
ReportReport
Posted on by 186

I have an array of around 300 items and want to know the position of a certain record so I can find out what my Flow is doing when it hits that record.   I can't just keep hitting "next" until I find it in the flow run history. 

 

I thought I'd create a smaller flow with a "Do until"  which has "ID" = 123432 (the id number) and increments a variable. But.. Automate insists on putting this inside an "Apply to each".  I'm fairly certain this creates a viscous loop as I had to end the run after 15minutes. 

How do I find the position of a certain Id within an array and return that number?

  • Verified answer
    PrasadAthalye Profile Picture
    on at
    Re: Find record in array and break "apply to each"

    You can use Terminate Action to Terminate the flow as soon as you find a match.

  • grantreid Profile Picture
    186 on at
    Re: Find record in array and break "apply to each"

    Yes, that would work. 

    I still find it stupid that the Apply to Each is automatically inserted into the flow.  If I have 300 items in the array and the target is found at number 14... it still has to go through 300 iterations. 

  • Verified answer
    PrasadAthalye Profile Picture
    on at
    Re: Find record in array and break "apply to each"

    @grantreid - You can declare a integer variable to 0 and increment within foreach using Increment variable action. Then when your id matches, you can set the value of this variable to another variable inside the match condition. Then use that variable to know the index..

     

    Like and Mark this as solution if this resolves your issue.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1