How to create HTML table for Get Items in Power Automate?

Summary

A question from user is that how to send multiple pending items from a list in an HTML table format.

The desired results in email is the following with ID, Title and Clickable link item.

The email from the Power Automate Flow.

Step by Step Solution

To make the flow simple I will just focus on how to get the above HTML table after getting items from the list let’s make a Manually triggered flow.

Step # 1 Create a manually triggered flow get all items from the FAQ list.

In your case you may have some more filter to get the items from the list, but for simplicity I am getting all items from an FAQ list.

Get items from an FAQ list

Step # 2 Use Create HTML table action to create table.

Map ID, Title and Link columns. See below
ID is mapped => item()?['ID']
Title is mapped to => item()?['Title']
Link is mapped to => concat('<a href="',item()?['{Link}'],'">Click Here</a>') 

# note the link will generate string like
<a href="https://blah blah blah">Click Here</a>

Step # 3 Now is the hard part, the expression to replace encoded html tags.

This is a required step, the output of the Create HTML Table does not put the HTML element as tags instead it put as encoded strings.

Compose to replace &lt, &gt;, &qout; &amp; with < > ” & respectively. Also add table border and padding.
# if you simply want to copy the expression use the following, but see below 
# for the explanation of replace.

replace(replace(replace(replace(replace(body('Create_HTML_table'), '&lt;', '<'), '&gt;', '>'),'&quot;','"'),'&amp;','&'),'<table>','<table border="1" padding="5">')

# Note the following is the breakdown of the above expression, 
# there are five replace expressions for '&lt;', '&lt;', '&quot;', '&amp;' and '<table>'.

replace(
  replace(
    replace(
      replace(
        replace(
           body('Create_HTML_table'), 
           '&lt;''<'
        ), 
        '&gt;' '>'
      ),
      '&quot;',
      '"'
    ),
    '&amp;',
    '&'
  ),
  '<table>',
  '<table border="1" padding="5">'
)

Step 4 Finally use the output of the Compose to send and email.

Send an email using the output of the compose.

Result

The Compose output will have properly formatted table which can be sent in an email body.

My inspiration is from the following awesome article.

Formatting HTML Tables in Flow | April Dunnam – SharePoint Siren

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to How to create HTML table for Get Items in Power Automate?

  1. brett says:

    Hey, just used this. Stumbled upon this after a Bing search and it was really helpful. Thanks for posting! πŸ‘

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s