Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Help with nested loops

(1) ShareShare
ReportReport
Posted on 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 at
    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
    43,407 Super User 2025 Season 1 on at
    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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May 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 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492