web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : tc763zE59T8DDEuls6hYp8
Power Automate - Building Flows
Unanswered

Help with nested loops

Like (1) ShareShare
ReportReport
Posted on 10 Oct 2023 14:06:57 by 25

Hello P Automate community,

 

I need help with the following flow, this is the problem statement:

 

"I need to send out one email to 5 different regions with a PDF attachment which is coming from 'Export file from Power BI'".

 

The emails should have this structure:

 

Email 1 for Region 'a'

  • Metric 1
  • Metric 2
  • Metric 3
  • Metric 4
  • Metric 5
  • Metric 6

Email 2 for Region 'b'

  • Metric 1 ...
  • Metric 6

I'm looping from two SharePoint lists, one with Region and one with Metrics, ideally I want the 1st loop to go through the region list, create the Power BI PDFs with the applied metrics and put all the PDFs in one single email. This is the error I'm getting:

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Attachment_Array' at line '1 and column '4259' cannot reference action 'Attachment'. The action 'Attachment' is nested in a foreach scope of multiple levels. Referencing repetition actions from outside the scope is supported only when there are no multiple levels of nesting.'.'.

 

Screenshot.png

 

Thanks for your help, I appreciate any ideas or suggestions.

  • esulyma Profile Picture
    25 on 10 Oct 2023 at 16:56:19
    Re: Help with nested loops

    Hi @FLMike 

     

    Are you able to generate a mockup flow with your suggestion? I have limited experience with variables.

     

    I appreciate your response.

  • Michael E. Gernaey Profile Picture
    45,345 Super User 2025 Season 2 on 10 Oct 2023 at 15:02:19
    Re: Help with nested loops

    Hi @esulyma 

     

    The issue is, that your trying to use an outputs that will be a loop. You cannot do that from outside and then re-use it somewhere else.

     

    You simply have to create your array inside the loop then use the Variable(array) directly. versus what you are doing. which is a double .. anyway it doenst like it.

     

    Make sure to set your Apply to each (click the ... Concurrency On, Value = 1)

     

    Then after you attach and send your next statement should be to set the Array to empty before doing it for the next region.


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

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!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2