Strategy 365

Solving common problems with HTML tables in Power Automate

Although Microsoft Power Automate is powerful, we look at overcoming three common issues with creating HTML tables.

What is the ‘Create HTML Table’ action?

This Power Automate action allows you to take output from a previous step and format it in a cleaner, tabular format to then be used in perhaps an email or Dynamics 365 record. It allows you provide custom table headers and enables you to quickly lay out your data. However, there are times when you need to go beyond its standard functionality and produce something a little more complex; this is where problems can potentially creep in.

Problem 1: Custom table headers don’t allow for spaces

Create HTML table

As you can see from the above image, it is not possible to enter a space in your custom table headers. To solve this, we need to add a new step in between the existing steps called Select (part of the Data Operations category):

Select Action

In the above image, you can see the new Select action and we have taken the output from our List rows step and used it to map fields to new key/value pairs, allowing us to use spaces in the labels. We then modify the Create HTML table action to use the output from the Select step and switch the Columns setting back to automatic. Our HTML table now has table headings with spaces.

Problem 2: Custom HTML links do not display correctly

There are times when listing data when you want to provide a link back to an individual record so that a user can go straight from an email to the data. However, as these links can be rather lengthy, you may want to try creating a custom link as below:

Create Link

However, when the email is received, you will find this does not display correctly:

Broken Links

This is due to Power Automate sanitising the output of the step to prevent the HTML causing problems. Should you want to work around this, you can add an additional Compose action (also part of the Data Operations category) to take the output of your table action and correct the HTML:

Replace HTML

The expression looks complicated but you can simply copy and paste the below and change the ‘Create_HTML_table’ part to the name of your table action if you have called it something else:

replace(replace(replace(body(‘Create_HTML_table’), ‘&lt;’, ‘<‘), ‘&gt;’, ‘>’),’&quot;’,'”‘)

When you then use the output from this Compose step in your email, you should get a much better result:

Create formatted link

Problem 3: Table formatting is  basic

As you can see from the previous problem, tables created by the Create HTML Table action look rather basic. With the addition of an extra Compose action, you can add a little formatting:

Table formatting

As you can see from the expression:

replace(replace(body(‘Create_HTML_table’),'<table>’,'<table border=”1″‘),'<td>’,'<td style=”padding:20px;”>’)

by swapping out parts of the HTML, we can add a border around the table and some cell padding. This could be further expanded to add further styling as required. The end result looks far neater:

Formatted table

Summary

We hope these tips prove useful to those building their own Flows within Power Automate. If you are an existing Strategy 365 client and wish to discuss any of the points raised in this blog post, feel free to get in touch with one of our experts.

Subscribe to the Strategy 365 monthly newsletter direct to your inbox.
Please see our Privacy Policy and Data Protection Policy for information on how we use your data
Enjoying our content?

Why not sign up to our email updates? You’ll receive a monthly newsletter and other timely information regarding events in the Microsoft world, including Dynamics 365 and the Power Platform, and related technologies, such as Microsoft 365.

Once subscribed, you can opt out at any time.