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

HTML Table in an Email always contains all items instead of a single item

Dear all,

 

Use Case:

I am building a flow to send an email 2 weeks before expiration of a certificate to the contact person of that item.

The table is a SharePoint List with 3 columns: Identification No, Valid Until, Contact Person.

 

Issue:

The html table always contains all items during that reporting time. So different contact persons always get all certificates expiring even they are not responsible for it.

 

Here is what I created:

 

Fn7a_0-1634729687304.png

Fn7a_3-1634729885238.png

Fn7a_4-1634729919831.png

Email Body contains: Outputs of HTMLTableStyling (CSS) and CleanHTML (to have a proper HTML table)

 

It would be great to have one email by contact person (containing all items expiring), but not containing these items which are not related to that contact person.

 

Could anyone tell me what I forgot to consider?

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-LilyW-msft
Community Support
Community Support

Hi @Fn7a 

If you want to send an email to Person(containing all items expiring), but not containing these items which are not related to that contact person. You can take a try with the following screenshots.

This is my test list.

vLilyWmsft_0-1634784652384.png

Flow in details:

vLilyWmsft_1-1634784692103.png

vLilyWmsft_2-1634784717494.png

vLilyWmsft_3-1634784908429.png

Expression:items('Apply_to_each')['ContactPerson/Email']

vLilyWmsft_4-1634784923209.png

vLilyWmsft_5-1634785006957.png

vLilyWmsft_6-1634785042332.png

vLilyWmsft_7-1634785075273.png

You can add HTMLTableStyling, I'm ignoring it here.

vLilyWmsft_8-1634785113037.png

After flow runs, Test2 and Litest will receive the following emails separately.

vLilyWmsft_9-1634785271454.png

vLilyWmsft_10-1634785288782.png

Hope the content above may help you.

Best Regards

If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
PrasadAthalye
Community Champion
Community Champion

Create a Array variable and run a loop on output from GetItems. Then add a condition to check if Person name has been already added to array variable or not using exist condition. If not, Add it. This way, you can collect all unique contact people.

 

Then run a loop on this array variable for each item and use filter array condition to filter GetItems output for that person which will give you rows related to that person. Then you can build your HTML and send email notification.

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
Fn7a
Frequent Visitor

Dear @PrasadAthalye ,

thank you for your suggestions, but I am not sure if I got what you explained in your post and how to reflect it properly. I am pretty new to this.

 

According to your first paragraph I did this:

Fn7a_0-1634736247487.png

 

Since I did not get the second paragraph at all I was just guessing:

Fn7a_1-1634736329705.png

 

Could you please guide me through your suggestion based on these screenshots?

Thank you

v-LilyW-msft
Community Support
Community Support

Hi @Fn7a 

If you want to send an email to Person(containing all items expiring), but not containing these items which are not related to that contact person. You can take a try with the following screenshots.

This is my test list.

vLilyWmsft_0-1634784652384.png

Flow in details:

vLilyWmsft_1-1634784692103.png

vLilyWmsft_2-1634784717494.png

vLilyWmsft_3-1634784908429.png

Expression:items('Apply_to_each')['ContactPerson/Email']

vLilyWmsft_4-1634784923209.png

vLilyWmsft_5-1634785006957.png

vLilyWmsft_6-1634785042332.png

vLilyWmsft_7-1634785075273.png

You can add HTMLTableStyling, I'm ignoring it here.

vLilyWmsft_8-1634785113037.png

After flow runs, Test2 and Litest will receive the following emails separately.

vLilyWmsft_9-1634785271454.png

vLilyWmsft_10-1634785288782.png

Hope the content above may help you.

Best Regards

If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fn7a
Frequent Visitor

Ok this is far to complex for me to build it on my own without your guidance. I am still going through it step by step to understand every action done. 

 

I was able to copy what you did with success. Many thanks for this detailed instruction!

The only open question I have is, how to include the Name of the Contact Person in the HTML table.

I managed to add a link to the item: 

Fn7a_0-1634808060669.png

But item()?['ContactPerson'] or item()?['Contact_x0020_Person'] or item()?['Contact_x0020_Person']?['Value'] did not work. Any suggestions?

 

Thanks

Hi @Fn7a 

Please use: item()?['ContactPerson/DisplayName'] and try again.
Best Regards.
Fn7a
Frequent Visitor

Hi @v-lilyw1-msft  / @v-LilyW-msft,

thank you for this suggestion, but even this did not fix it:

Fn7a_0-1634812680290.png

Fn7a_1-1634812703125.png

Any other idea?

 

 

v-LilyW-msft
Community Support
Community Support

Hi @Fn7a 

I tested it on my side and can get the name of the user. Please check if the internal name of your ‘Contact Person’ column is ‘ContactPerson’.

vLilyWmsft_0-1634866295585.png

vLilyWmsft_1-1634866310138.png

Best Regards.

 

Fn7a
Frequent Visitor

Even after recreating the column without blank space in between and using _x0020_ i run into the same issue. Thats how my column is configured. Anything different to yours?

Fn7a_0-1634881418779.png

 

 

This is the overall overview of my flow:

Fn7a_1-1634881534638.png

 

Similar to yours:

Fn7a_2-1634881580943.png

 

 

Thanks

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (3,428)