cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asAdmin
Frequent Visitor

How to get the numbered iteration in an Apply To Each function?

I have a flow that when a sharepoint list item is created, it gets the attachments from that list item, loops over them using Apply To Each, and for each one, creates a file in a sharepoint document library. This works great, except when I get to naming the files. I can do this successfully with a static file name or a dynamic name from the list item but I am trying to name them dynamically, so that each iteration adds that number iteration to the file name. For example, if I had 3 attachments, it would name the files:

 

'Picture 1'

'Picture 2'

'Picture 3'

 

I am having trouble figuring out how to capture which iteration the Apply To Each is on, in order to append it to the file name. It either needs to keep a count during the iteration or it needs to know the total amount of attachments before the Apply To Each so I can try to attach the number that way? Any thoughts on best way to know the current iteration or a way to count through the iterations?

1 ACCEPTED SOLUTION

Accepted Solutions
asAdmin
Frequent Visitor

Nevermind I figured it out. You can initialize a variable outside of the Apply to Each, then use the Increment Variable inside the Apply To Each to increment it through each iteration. Then you can set that variable into the file name.Screen Shot 2018-10-10 at 7.27.07 AM.png

View solution in original post

3 REPLIES 3
asAdmin
Frequent Visitor

Nevermind I figured it out. You can initialize a variable outside of the Apply to Each, then use the Increment Variable inside the Apply To Each to increment it through each iteration. Then you can set that variable into the file name.Screen Shot 2018-10-10 at 7.27.07 AM.png

Anonymous
Not applicable

Unfortunately, this [The function 'iterationIndexes'] does not seem to work for "Apply To Each", but only for "Until" loops. It is a weird design to have such a function only work for one of the two loop types - but here we are.

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.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,921)