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

Email Users who were Assigned Task when Completed (Planner)

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' and column '31334': 'The template language expression 'outputs('Get_user_profile_(V2)')?['body/mail']' cannot be evaluated because property 'body/mail' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'."

 

Not sure what I'm doing wrong - can anyone help? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

The content from 'Apply to each' doesn't make it outside of the 'Apply to each'. If you need to build a list of all approvers to send the email, you should:

  • 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')


[ 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

6 REPLIES 6
tom_riha
Super User
Super User

Hello @kdillon ,

try to delete the email address dynamic content in the 'Send an email' action and enter it again, it seems it's not correct.



[ 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. ]
kdillon
Frequent Visitor

Thanks for the reply @tom_riha

I deleted it and now it doesn't let me repopulate it with the "mail" item I had before. The only options for dynamic content are from the planner (get task details) and "current item" from apply to each?

Then I'd try to recreate also the 'source' action for that email. There must be something broken in one of the actions in your flow. Maybe try to delete the whole 'Apply to each' and build the email sending part again.



[ 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. ]
kdillon
Frequent Visitor

@tom_riha 

kdillon_1-1618415998882.png


Maybe I'm doing something else wrong? I rebuilt everything after "When a task is completed". It seems like it correctly gets the tasks details, the "apply to each" loops through the "get user profile" and pulls all the data from the 4 users in my test but I can't seem to send them to the send an email part. I'm not a programmer or anything but based on what it's saying, it sounds like it stores all 4 users in an array and the email v2 doesn't understand how to pull the individual users from that array? Maybe something is supposed to be in between the apply to each and send an email?

 

The content from 'Apply to each' doesn't make it outside of the 'Apply to each'. If you need to build a list of all approvers to send the email, you should:

  • 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')


[ 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. ]
kdillon
Frequent Visitor

@tom_riha 

 

This worked! Thank you so much

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,371)