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 / Help with nested loops
Power Automate
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.

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at

    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

  • esulyma Profile Picture
    25 on at

    Hi @FLMike 

     

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

     

    I appreciate your response.

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard