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 : 7zVsZp3vG6fQul2BBwBKiz
Power Automate - General Discussion
Answered

Flow Automatically Creates Foreach Loop

Like (0) ShareShare
ReportReport
Posted on 10 Dec 2018 14:16:30 by 68

I'm attempting to create a simple notification Flow. It waits for a SharePoint list item to be changed and for a field to equal "Completed." In the Yes branch, I'm attempting to fire off three emails whose body text is based on information collected in the list. The fields are choices and text. For some reason, when I add one of my text fields in the body text of the 3rd email, Flow decides that my email step needs to be encapsulated in a Foreach loop.

 

The wisdom of having software make automatic decisions on the logical structure of a workflow notwithstanding, does anyone know how to prevent this? Or am I going to have to create another workflow to send this email?

 

  • Kavita_6032 Profile Picture
    18 on 13 Dec 2024 at 12:41:29
    Flow Automatically Creates Foreach Loop

    Hello Everyone,

    Earlier I have Created this flow like this and It was working fine.


    But now getting this error  
    Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'For_each' referenced by 'inputs' in action 'Get_items' are not defined in the template.'.'.


    Please help to fix this issue.

    Thanks
  • v-bacao-msft Profile Picture
    on 19 Dec 2018 at 07:24:22
    Re: Flow Automatically Creates Foreach Loop

    Hi @rgbrasel,

     

    Have you had an opportunity to apply Scott’s workaround to adapt your Flow?

    If your problem have been solved, please go ahead and mark your post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

    If you need further assistance, please feel free let me know.

     

    Best Regards,

    Barry

  • rgbrasel Profile Picture
    68 on 10 Dec 2018 at 18:48:37
    Re: Flow Automatically Creates Foreach Loop

    Ah! That makes sense now. I'm going to attempt that and post the results. Tomorrow--my brain is getting a little tired.

  • Verified answer
    ScottShearer Profile Picture
    25,236 Most Valuable Professional on 10 Dec 2018 at 18:46:11
    Re: Flow Automatically Creates Foreach Loop

    @rgbrasel:

     

    If you reference a column that can have multiple values, Flow will automatically put you into a loop.  That's why it loops when you reference your choice column - check boxes mean you can select multiple values.  I don't know why this would happen for a text column - it should not.

     

    One work around is to loop through the choice column and append each value to a string variable.  Then, reference the variable in the email.  The email should obviously be outside and after the loop.

     

    If this answers your question, please mark your post as solved.

     

    Scott

     

  • rgbrasel Profile Picture
    68 on 10 Dec 2018 at 17:51:01
    Re: Flow Automatically Creates Foreach Loop

    The choice field is set up to display checkboxes and allow fill-in choices. I also just attempted to set a string variable based on that field, and the moment I tried to set the variable, it applied another foreach loop.

     

  • rgbrasel Profile Picture
    68 on 10 Dec 2018 at 17:44:25
    Re: Flow Automatically Creates Foreach Loop

    If it helps, this is part of the Yes branch following a Condition.

  • rgbrasel Profile Picture
    68 on 10 Dec 2018 at 17:05:08
    Re: Flow Automatically Creates Foreach Loop

    The foreach loop is automatically generated when I add the Technology Information Value to the Body Text. That column is a choice type that allows multiple selections.

    ScreenshotScreenshot

  • ScottShearer Profile Picture
    25,236 Most Valuable Professional on 10 Dec 2018 at 16:51:21
    Re: Flow Automatically Creates Foreach Loop

    @rgbrasel:

     

    Can you post a screen shot of your Flow?  That will make it easier to assist.

     

    Scott

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

Loading complete