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

Dynamic table row count to eliminate blank rows in HTML email

l followed this guide to create an HTML template email:
https://www.matthewdevaney.com/send-formatted-emails-from-power-apps-without-writing-any-html-code/

 

This email is triggered automatically upon adding an item to a SharePoint list. The email includes a table which includes data from the SP list item. The challenge I'm facing now is if it is possible to make the table length change dynamically, since in some cases there are empty rows. Within each item, there may be anywhere from 1-25 rows and this should adjust dynamically. Is it possible to truncate the table length?

Example. Instead of an email like this:

RodM_0-1656102816359.png

 

 

I'd like the flow to dynamically eliminate excess rows to show an email like this:

RodM_1-1656102830407.png

 

 

5 REPLIES 5
EddieE
Super User
Super User

@RodM 

You say that an email is triggered upon a new item added to your list which likely means you using a Flow. You’ll need to show us details of that Flow because that’s where you’ll need to adjust this

v-bofeng-msft
Community Support
Community Support

Hi @RodM ,

 

You could consider using filter+forall to generate dynamic HTML text.

For example:

 

"<table>
    <tbody>
        <tr>
            <th>Column1</th>
            <th>Column2</th>
            <th>Column3</th>
        </tr>"&
Concat(ForAll(
  Filter(TheSPList,!IsBlank(Column1)),
  "<tr><td>"  & 
  Column1     &  
  "<tr><td>"  & 
  Column2     &
  "<tr><td>"  & 
  Column3     &
  "</td></tr>"
),Value)

&
    "</tbody>
</table>"

 

Best Regards,

Bof

RodM_0-1656336624948.png

The variable invoked is used to turn a multi-person Person column into a string for emailing.

 

Would you need to see the HTML code I'm sending for the email

Can you provide a sample data structure so that I can understand this better?

@RodM 

If you are collecting your table data inside the Flow then you can use an Array. What I do is

 

1. Create a blank Array Variable

2. Then inside an Apply to Each use Append to Array step. This is written in JSON

3. Then, once the Apply to Each is done parse that finished Array to a Create HTML Table step. Flow then builds the table for you

 

If the data is getting generated in PowerApps then parse to Flow something like what @v-bofeng-msft has suggested will work for you.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,627)