cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alberto1
Helper III
Helper III

Send Single Email Per Contact from SharePoint List including Table

Hello,

 

I am trying to build a flow to, upon running it, automatically send a single email per PM contact with relevant information of each related project aggregated in a table. PM contact and information per project is extracted from a SharePoint List.

PM Contact is a single line text field/column containing an email address (ex. JohnSmith@company.com).

 

I tried a few attempts, in my latest flow:

a. 1 email per project was being sent instead of 1 email per PM contact

b. The same project was being repeated on several rows instead of aggregating projects per PM

c. Since it is an HTML table I believe, I am getting the full path/div class instead of just the answer (as an example under Changes here I should only get No) 

 

Few columns from SharePoint List:

alberto1_2-1631728438226.png

 

Latest Email Table:

alberto1_3-1631728641198.png

 

Latest Flow:

alberto1_1-1631728410079.png

 

alberto1_0-1631728381057.png

 

All help and advice is appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

In case anyone looks at this at a later time, I was able to resolve my issue as follows:

 

1. Added a Select  after Table CSS

  1. From: Body of the Filter Array: body('Filter_array') (you should be able to select it in Dynamic content)
  2. Map: Use the value you need in Enter value, you can leave Enter Key empty unless needed: enter the following expression: item()?['field name']

2. Added a Compose to turn the select array into a string with this expression:  string(body('Select')) in my case I renamed the select so it was string(body('Select_Project_ID'))

 

3. Added another Compose to clean up the string using this expression: 

replace(replace(replace(replace(replace(replace(replace(outputs('Compose'), '['''), ']'''), '{'''), '}'''), ','', '), '"'''), ':'''); in my case I renamed the Compose to Project_ID
 
4. I was able to use the clean output from the last compose (you can find it in Dynamic content) in the email as per below
 
alberto1_0-1632249907365.png

 

Here's the full flow for this loop:

 

alberto1_1-1632250048439.png

 

I cleaned the HTML Table using this expression in a Compose (Replace Special Characters in the above snapshot):

replace(replace(replace(replace(replace(replace(replace(body('Create_HTML_table'), '&lt;''<'), '&gt;''>'), '&amp;''&'), '&#39;''"'), '&#58;'':'), '&quot;''"'), '<br>'' ')
 
Some useful Links

View solution in original post

8 REPLIES 8
eric-cheng
Solution Sage
Solution Sage

Hi @alberto1 ,

 

So just to confirm, you want to send 1 email to each contact which aggregates their project ID and changes?

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Hi @eric-cheng,

 

Yes, that's correct!

 

I want to send 1 e-mail per contact, aggregating Project ID and changes per project in a table, where all the information per Project ID is on a SharePoint List, including the contact email address. 

eric-cheng
Solution Sage
Solution Sage

Hi @alberto1 ,

 

Please check out the post here which has two solutions for a group by functionality.

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Thank you @eric-cheng.

 

I will look into it and try to implement it.

 

I will let you know how it goes and we can take it from there!

Hi @eric-cheng,

 

I finally managed to replicate the flow indicated in the post/article (http://johnliu.net/blog/2018/6/do-group-by-in-flow-with-two-simple-elegant-loops😞

alberto1_0-1631893998409.png

 

However it seems it only works as long as you are not using dynamic content.

As soon as you try to use Dynamic Content anywhere, it automatically creates an additional Apply to Each loop which seems to mess up the flow:

 

alberto1_2-1631894469049.png

 

When I attempted this I got the following error message:

"Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Append_to_array_variable' at line '1 and column '2667' cannot reference action 'Select'. The action 'Select' 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.'.'."

 

Any ideas on how to handle this?

 

Thank you!

Ok nevermind, I made this part work, by using an expression for each entry:

item()?['field name']

Hi @eric-cheng,

 

I am stuck at the email part now, can't seem to figure out the correct expression to get Dynamic Content while avoiding an additional loop. I tried items('ForEach_Unique_PM')?['Project_x0020_ID']', and ended up with the following error:

Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '1' and column '31935': 'The template language expression 'items('ForEach_Unique_PM')?['Project_x0020_ID']' cannot be evaluated because property 'Project_x0020_ID' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'. 

 

alberto1_3-1631897547200.png

Any ideas?

 

Thank you!

In case anyone looks at this at a later time, I was able to resolve my issue as follows:

 

1. Added a Select  after Table CSS

  1. From: Body of the Filter Array: body('Filter_array') (you should be able to select it in Dynamic content)
  2. Map: Use the value you need in Enter value, you can leave Enter Key empty unless needed: enter the following expression: item()?['field name']

2. Added a Compose to turn the select array into a string with this expression:  string(body('Select')) in my case I renamed the select so it was string(body('Select_Project_ID'))

 

3. Added another Compose to clean up the string using this expression: 

replace(replace(replace(replace(replace(replace(replace(outputs('Compose'), '['''), ']'''), '{'''), '}'''), ','', '), '"'''), ':'''); in my case I renamed the Compose to Project_ID
 
4. I was able to use the clean output from the last compose (you can find it in Dynamic content) in the email as per below
 
alberto1_0-1632249907365.png

 

Here's the full flow for this loop:

 

alberto1_1-1632250048439.png

 

I cleaned the HTML Table using this expression in a Compose (Replace Special Characters in the above snapshot):

replace(replace(replace(replace(replace(replace(replace(body('Create_HTML_table'), '&lt;''<'), '&gt;''>'), '&amp;''&'), '&#39;''"'), '&#58;'':'), '&quot;''"'), '<br>'' ')
 
Some useful Links

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 Solution Authors
Users online (2,287)