All documentation

Inserting Clickable Hyperlinks into an HTML Table in Power Automate

Published April 17, 2024 Guide

Purpose

This document provides a guide on how to create clickable hyperlinks within an HTML table generated in Power Automate, using a variable to build the table, and then applying a regular expression to ensure proper rendering of HTML tags.

Scope

This process is applicable to scenarios where an HTML table with clickable links needs to be generated and sent via email or displayed in a web-based platform.

Procedure

Initializing the Array Variable

  1. Start by initializing an array variable (ArrayVariableName) that will hold the JSON objects representing the rows of your HTML table.

Adding Links to the Array Variable

  1. Within your flow, wherever you are generating the items that will go into the HTML table, use the Append to array variable action.
  2. In the 'Value' field of this action, construct your JSON object with the HTML link included. Here’s the format:json
  3. { "Change": "<a href=\"https://link.com\">texthere</a>" }


Creating the HTML Table

  1. After constructing your array with all necessary items, add the 'Create HTML table' action.
  2. For the 'From' field in the 'Create HTML table' action, use the array variable (ArrayVariableName) that contains your JSON objects.

Unescaping HTML Characters

  1. Next, add a 'Compose' action to unescape any HTML characters that may have been escaped during the creation of the HTML table.
  2. In the 'Inputs' field of the 'Compose' action, use the following expression:plaintext
  1. replace(replace(replace(body('Create_HTML_table'), '&lt;', '<'), '&gt;', '>'), '&quot;', '"')

Using the Unescaped HTML

  1. Now you can use the output of the 'Compose' action in subsequent steps, such as inserting the HTML table into an email. The links will be properly rendered and clickable in the received email.

Testing

  1. Make sure to test the flow thoroughly to confirm that the links appear correctly and are clickable in the final output.

Conclusion

By following these steps, users will receive an HTML table where the 'Change' column contains clickable hyperlinks, providing a seamless and interactive experience.