cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Starpiter
Frequent Visitor

Email Users who were Assigned Task when Completed (Assignees)

I'm trying to build a flow that automatically emails all users who were assigned a task that it was completed. 

 

The flow starts off with "When a task is completed" -> Get Task Details -> Apply To Each -> Get User Profile (Assignments) -> Send an Email V2

 

The apply to each seems to correctly pull the email addresses from the planner item but the Send An Email V2 throws the following error: ""Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '1' ..."

 

Trying to follow the steps within the previous example i have not been able to resolve. when i attempt to 'Append to string variable' it asks me for a name

 

  • Initialize a string variable
  • Inside 'Apply to each' after the 'Get user profiles', 'Append to string variable' the user email address with semicolon at the end, that will give you a variable with all the emails
  • 'Send an email' to that variable (outside of the 'Apply to each')

https://powerusers.microsoft.com/t5/Building-Flows/Email-Users-who-were-Assigned-Task-when-Completed... 

 

Flow.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Starpiter ,

you don't need to split anything, just add ; after the Email dynamic content in the 'Append to string variable'.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

5 REPLIES 5
tom_riha
Super User
Super User

Hello @Starpiter ,

you can't use 'Current item' dynamic content outside 'Apply to each'. Current item is the currently processed item in a loop. If you want to send an email outside the loop, you must store it in a variable.

And the Name the variable asks from you is the name of that variable. Initialize a variable, give it a name, and then update it in the flow.

Btw. I think the flow also won't like that you're trying to initialize a variable inside a loop, I think it has to be before that loop.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
Starpiter
Frequent Visitor

Hi @tom_riha 

 

Thank you, i appreciate the help. It feels like i am turning a simple flow into something more complex than it needs to be and are going around in circles now.

 

I have set the flow as follows and having no joy:

 

  1. When a task is completed
  2. Apply to each
    1. 'Value assignments Assigned to User ID'
      1. Intiailize Variable
        1. Get Users
        2. Boolean
        3. 'Value assignments Assigned to User ID'
      2. Get User Profile (V2)
        1. 'Value assignments Assigned to User ID'
      3. Append String to variable
        1. ?
  3. Send an Email (V2).

 

I keep getting the '

The template validation failed: 'The inputs of template action 

 

'Send_an_email_(V2)' at line '1 and column '2445' is invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of action 'Send_an_email_(V2)' to be referenced by 'repeatItems' or 'items' functions.'​

Error

 

 

Flow 2.jpg

Hello @Starpiter ,

you're missing the variable where you'll store all the emails:

image.png

Also, in the 'Append to string variable', you should add ; behind the 'Mail' dynamic content to separate the email addresses.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Hi @tom_riha 

 

It feels like i'm getting closer. Just struggling with the last part "behind the 'Mail' dynamic content to separate the email addresses."

 

Within the "Append to string" i have tried the Mail and also Split (using either a comma and semi colon) and keeps bringing up the same error.

 One or more recipients are invalid.

clientRequestId: xyz

serviceRequestId: xyzIs

 

It also possible to remove or replace a specific email if it exists, as it looks like will email the whole planner board group?

 

split(body('Get_user_profile_(V2)')?['mail'],',') ​
["Email1@address.co.uk"]["Email12@address.co.uk"]["Email3@address.co.uk"] 

 

Flow 3.jpg

 

 

@tom_riha

Hello @Starpiter ,

you don't need to split anything, just add ; after the Email dynamic content in the 'Append to string variable'.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Kudoed Authors
Users online (2,757)