cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Xiarno
New Member

Loop throws index out of range.

So I'm trying to have the name of all folder in a folder, then remove the file path of the name so I can get the name alone. It gives me an index error, but it still works great so it doesn't really matter there. The thing is, this was one part of a bigger flow. And when this error get thrown, it stops the rest of the flow, which is a problem there.

Xiarno_0-1644360872980.png

Xiarno_1-1644360883209.png

How to fix this if possible please ?

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelAnnis
Super User
Super User

Loop 0 to %Folders.Count - 1%

 

Since the list has a 0 based index, there is 1 less index than number of rows.  Count returns the number of rows, so you have to subtract 1 to loop on indexes.

View solution in original post

2 REPLIES 2
MichaelAnnis
Super User
Super User

Loop 0 to %Folders.Count - 1%

 

Since the list has a 0 based index, there is 1 less index than number of rows.  Count returns the number of rows, so you have to subtract 1 to loop on indexes.

itomti
Advocate I
Advocate I

Dunno, to me it seems like loops should be < not <= when doing the Count or Length comparison.

 

Seems strange that this stayed the same since WinAutomation transition.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,895)