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 / Nested Loops Workaround
Power Automate
Unanswered

Nested Loops Workaround

(0) ShareShare
ReportReport
Posted on by 19

Inputs

  • SharePoint List - contains the following columns
    • Site Name
    • Contacts
  • SharePoint Document Library
    • File names which contain the Site Name string

 

I'm trying to create a flow that goes item by item through a SharePoint list, find the files within a SharePoint document libary that contain the specific site name, and then emails those files to the contacts specified in the above list on a fixed schedule.

 

For example, the SharePoint list will have an entry where the Site Name = "Group ABC", with Contacts = "John Doe; Jane Doe". The Flow would loop through the list, hit that entry, then search the document library for any files that contain the string "Group ABC". Ideally, it would then package each of those files into a single email which gets sent to John Doe and Jane Doe. I'm not sure if that last part is possible, so if necessary, we can send 1 email per file.

 

The problem I'm having is that the straightforward way of creating this flow requires me to have nested loops. Top loop that cycles through the List, with a nested loop that then cycles through the Document Library for each list item. Flow does not currently support nested loops, but I feel like there has to be some workaround I could use that would allow this without creating nested loops. Just can't figure out how to structure it in a way that Flow allows.

 

Any ideas?

Categories:
I have the same question (0)
  • Bizzo Profile Picture
    212 on at

    I wasn't sure how you were triggering your first flow, so I went with a recurrence trigger and added a column so only the list items that haven't been checked are checked.

     

    SharePoint List - contains the following columns

    • Site Name
    • Contacts
    • IsChecked
    • IsCheckedDate

    Flow runs every 5 mins, gets any rows from above list where [IsChecked] eq No (for example). Use an apply to each on the results returned. Insert [Site Name], [Contacts] into second list. Set [IsChecked] to Yes and [IsCheckedDate] to @utcnow().

     

    SharePoint List 2

    • Site Name
    • Contacts
    • Other columns depending on what info you want to record.

    Flow is triggered when a new item is inserted into List 2. Gets files from Library when filename contains [Site Name] (from List 2). Use an apply to each on the results returned. Send an email with each file attached (I assume you can attach a file? I usually just send a link, but it sounds like you want the file(s) attached) to the people listed in the [Contacts] column. Once the apply to each has completed, you could update any additional columns in SharePoint List 2.

     

    If you don't need the file attached, you could actually build a string with links to each file inside your apply to each loop, and after the apply to each has completed you could email out a single email to everyone and it would have a list of all the files and links to the files.

     

    I think that will work...

  • dprjustin Profile Picture
    19 on at

    Thanks for the reply. Flow will not let me write the Contacts field (Person or Group type) from one list to another. Initially I figured that Flow did not support multiple selections in this field (is that correct?), however, when I changed it to prevent multiple selections, I am still unable to write the contacts field.

     

    It was my understanding that 'Person or Group' fields were now supported in Flow. Is this not the case?

     

    flow1.jpgflow2.jpg

  • Bizzo Profile Picture
    212 on at

    I'm not aware of all the limitations of the Person/Group column types, but they have given me some headaches. What I've done in situations where people need to send multiple emails is have them enter in each email address as a semi-colon separated string, which can be used in the "To" field to send an email. It's not ideal, but it's a reasonable workaround for now.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard