Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

How to add hyperlink in the ‘Create HTML table’ Power Automate action

Posted on June 16, 2021June 16, 2021 by Tom

“I’ve got all the items in a single HTML table, but I’d like to include also clickable hyperlink to the items, is that doable with Power Automate?”


The Power Automate action ‘Create HTML table’ should allow you to display data in an ‘easy to read’ format. But as already shown on the multiple people picker or choice SharePoint columns, sometimes it’s not that easy. If you use the HTML table to send data to users, you might need to format them it a bit. And another value that needs formatting is the link to the related item / document. You probably don’t want to send the whole link, and this post will show you how to avoid it.

Power Automate HTML table hyperlink

Note: All the examples below will use a SharePoint list as the data source.

Format the link with HTML tags

Since you’re building an HTML table, you should stick to that format and build the link in HTML format too.

<a href="Link">Text to display</a>

Using Power Automate, such a string can be built with the concat(…) expression from the various pieces.

concat('<a href="', [Link], '">[Text]</a>')

Replacing the placeholders with actual values, the expression might look like below.

concat('<a href="', item()?['{Link}'], '">Link to item</a>')

But this is only the first step of the solution. If you end here, you’ll make the link even uglier as you can see below. The action took the string as it is, without applying the HTML tags.

What happened is that the HTML table doesn’t want you to add another HTML tags as they could break the table. To stay safe it replaced the < with &lt;, > with &gt; and “ with &quot;. It’s just another representation for these characters, but it’s enough for the table to ignore the additional HTML code with the hyperlink. That leads to the 2nd step, you must replace the characters back.

Return the <, > and ” characters

To hide the links and show only the text (with link in the background), you must get back the <, > and ” characters. That means using the replace(…) expression on the ‘Create HTML table’ output to replace the &lt;, &gt; and &quot;.

1. replace(body('Create_HTML_table'),'&lt;','<')
2. replace(body('Create_HTML_table'),'&gt;','>')
3. replace(body('Create_HTML_table'),'&quot;','"')

or all together in a single expression:
replace(replace(replace(body('Create_HTML_table'),'&lt;','<'),'&gt;','>'),'&quot;','"')
Power Automate HTML table hyperlink

Use another dynamic content as the text

Now, when you know how to hide the link behind a text, you can adjust also the text itself. The easiest way is to have a static text for the link, but it’s not necessary. You can use another dynamic content as the text too, just add it to the concat(…) expression, e.g. the item title.

concat('<a href="', item()?['{Link}'], '">', item()?['Title'], '</a>')
Power Automate HTML table hyperlink

Summary

I’d say this post is an addition to the previous post on formatting the HTML table. When you use Power Automate to send reminders or reports with an HTML table, it makes sense to include also hyperlink. It’ll change a purely information email into an actionable email, and the recipients will save a lot of ‘search time’. Quick overview of the most important values and a link to see them all.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

11 thoughts on “How to add hyperlink in the ‘Create HTML table’ Power Automate action”

  1. Brian says:
    August 17, 2021 at 11:17 pm

    Excellent solution, thank you!

    Reply
  2. Colleen says:
    October 28, 2021 at 6:39 pm

    This is EXACTLY what I was looking for. Thank you!

    Reply
  3. Tom Kaphingst says:
    December 22, 2021 at 3:48 pm

    This is great, I have a need to add multiple attachment links per item. How is that processed/ how would I process that?

    Reply
    1. Tom says:
      December 30, 2021 at 9:52 am

      Hello Tom,
      you’d use the same approach, but you’d have more rows in the ‘Create HTML table’ action where you build the additional links in the same way with the concat(…) expression.

      Reply
  4. Kayla says:
    March 25, 2022 at 11:37 pm

    Thank you so much!

    Reply
  5. Oscar says:
    May 15, 2022 at 7:51 pm

    Not sure where you are saying we put the replace, replace commands in. If I do in the body of the email, I still get the long URL. And then where do you ever pull the output from as in the replace, replace command you gave, I see reference to create html table but nothing about the output.

    Reply
    1. Tom says:
      May 17, 2022 at 8:37 am

      Hello Oscar,
      the long replace(…) expression should be in the email body, but for it to do anything you must use also the concat(…) in the ‘Create HTML table’ action that’ll prepare the string with the characters to be replaced.

      Reply
  6. Alex says:
    May 25, 2022 at 12:19 am

    Hi Tom, first of all congrats for the post.

    Second thing: I did exactly what you said. An email is sent out with the Custom HTML table and the hyperlinks created the way you state, including the replace replace replaces, etc.

    But once it arrives to my Inbox, be it Gmail or Yahoo, the links are simply not clickable . Or when clicking on them, nothing happens. No browser page gets opened with the link.

    And this happens in Gmail , or Yahoo, and using them from either my Desktop Outlook or via browser.

    Any idea?

    Best,

    Alex

    Reply
    1. Tom says:
      June 1, 2022 at 5:29 pm

      Hello Alex,
      the links are build using HTML coding so every client that supports HTML emails should handle them. I’m surprised that it doesn’t work in the clients, does it look like a valid HTML when you check the email code?

      Reply
  7. Olga Melo says:
    June 7, 2022 at 10:49 pm

    You are brilliant!
    I just copy paste and got a perfect working solution.
    Thank you very much for all the content you share.

    Reply
  8. Mike says:
    June 11, 2022 at 3:53 am

    Awesome blog! You saved me much hair

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme