Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Flow save failed with code 'InvalidTemplate' and message

(0) ShareShare
ReportReport
Posted on by 2

Hi, I am hoping someone can help me figure out why I can't save my flow. I keep getting the error message:

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'Apply_to_each' referenced by 'inputs' in action 'Send_an_email_(V2)' are not defined in the template.'.'.

 

I am attaching a screenshot of the entire flow. 

 

The goal: a single request form (uses Microsoft Forms) that sends approval requests to various people depending on the type of request submitted and the approver needed, then emails the requester letting them know if their request is approved or rejected. "Condition 2" identifies 1 of 4 options of request types - the other three all go to the same approver. If this expense type is selected, they will then select 1 of 3 approvers ("Switch").

 

Thank you for any help you can provide. 

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at
    Re: Flow save failed with code 'InvalidTemplate' and message

    @tl88  its still not correct, please follow below steps:

     

    1. Add Initialize variable at top of your flow, name it "ApproverName" and select type as string

    annajhaveri_0-1669961548740.png

     

    2. Again add Initialize variable at top of your flow, name it "ApproverComments" and select type as string

    annajhaveri_1-1669961586035.png

     

    3. Now after the wait for approval action, add Set variable action. Select ApproverName variable and in value select "Responses Approver Name" from dynamic content, so the Set variable action will look as follows:

    annajhaveri_2-1669961698339.png

    4. Now again add Set Variable action below the action that you added in above step and here select ApproverComments variable and in value select "Responses Comment" from dynamic content, so the Set variable action will look as follows:

    annajhaveri_3-1669961781606.png

     

    Now inside your Send Email action, use the ApproverName and ApproverComments variables instead of using Responses from Approval action.

     

     

  • tl88 Profile Picture
    2 on at
    Re: Flow save failed with code 'InvalidTemplate' and message

    Thank you for trying to help. Unfortunately, this does not seem to have solved the problem. I am getting the following error message:

    Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Send_an_email_(V2)_5' at line '1 and column '11728' is invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of action 'Send_an_email_(V2)_5' to be referenced by 'repeatItems' or 'items' functions.'.'.

    Flow attached.

    screencapture-make-powerautomate-environments-Default-6f21da2f-d84b-4187-9300-1485f11536c5-flows-eb1d53e8-181e-47b1-bd76-9066ac9db2d9-2022-12-01-14_18_40.png

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at
    Re: Flow save failed with code 'InvalidTemplate' and message

    @tl88  to get approver's name and comments you need apply to each action, please see this post on how to get approver's name https://powerusers.microsoft.com/t5/General-Power-Automate/Access-name-of-the-approver-with-out-apply-to-each/td-p/826799 and same way you can get approvers comments, then use those variables in the Send Email action.

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

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!

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 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1