web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Help with replace and ...
Power Automate
Unanswered

Help with replace and HTML in create table

(0) ShareShare
ReportReport
Posted on by 7

Hey Community,

I have a flow that I am building and in it I am creating an array and converting that into a HTML Table to send via email.

 

For context the Array looks something like this:

 

[

{

"Col1":"I am a test column",
"Col2":"I am another test columns",
"Col3":"<strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>"

},

{

"Col1":"I am a test column",
"Col2":"I am another test columns",
"Col3":"<strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>"

},

{

"Col1":"I am a test column",
"Col2":"I am another test columns",
"Col3":"<strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>"

}

]

the HTML table that comes out via email ends up looking something like this:

 

Col1Col2Col3
I am a test columnI am another test columns<strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>
I am a test columnI am another test columns<strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>
I am a test columnI am another test columns <strong>Hello World</strong><br>Test Value:<strong><br>Result Value:</strong>

 

I wanted it to output like this:

 

 

Col1Col2Col3
I am a test columnI am another test columns

Hello World

Test Value:

Result Value:

I am a test columnI am another test columns

Hello World

Test Value:

Result Value:

I am a test columnI am another test columns

Hello World

Test Value:

Result Value:

 

It outputs the HTML as plain text. I am assuming I need to do some magic with the replace function to get the desired result but I have tried a few options and am hitting a wall.

 

Please can someone help with this

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,181 Most Valuable Professional on at

    Hi @AJPowerfulBI,

     

    Is by any chance the body of your e-mail showing characters like &lt;? It is very likely that the < less than character and other HTML characters are rendered with their entity name.

     

    HTMLentitynames.png

     

    Try an expression like below to avoid this.

    replace(replace(replace(body('Create_HTML_table'),'&lt;','<'),'&quot;','"'),'&gt;','>')

     

    HTMLentitynames02.png

     

  • AJPowerfulBI Profile Picture
    7 on at

    Wow thanks for lending a hand 🙂 this was very helpful. This was 100% the solution to what was happening. I applied the same logic to the email and other areas and it fixed everything 🙂 .

     

    thanks again 😄

  • perlite77 Profile Picture
    2 on at

    Hello Dennis,

    Hope you are well. 

    I am developing a Power Automate Flow that is fetching documents from SharePoint document library and returning results to Copilot Studio in a table format as below. I am using three parameters in flow 1. Title, 2. Product Category and 3. Document Type (e.g. SOP or a Form etc.).

    Below table works fine if I have only one parameter e.g. Title. 

    perlite77_4-1712173811663.png

    Complete Flow

    perlite77_3-1712173696989.png

     

    Now when I included two parameters e.g. "Title" and "document type" then I received error: Unable to process template language expressions in action 'Return_value(s)_to_Power_Virtual_Agents' inputs at line '0' and column '0': 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#replace for usage details.'. 

     

    I used following code in last step of Flow, i.e Return Values to PVA.

    replace(replace(replace(replace(replace(replace(replace(body('Create_HTML_table'), '<table><thead><tr><th>', '| '), '</th></tr></thead><tbody>', concat(' |',decodeUriComponent('%0A%0D'),'|-----------|:-----------:|',decodeUriComponent('%0A%0D'))), '</th><th>', ' | '), '<tr><td>', '| '), '</td><td>', ' | '), '</td></tr>', concat(' |',decodeUriComponent('%0A%0D'))), '</tbody></table>', '')

    perlite77_0-1712172840656.png

    Could you help with a correction to below for more than one parameter in user question so that results can be communicated to user as a table in Copilot Studio bot.

    Many thanks.

    replace(replace(replace(replace(replace(replace(replace(body('Create_HTML_table'), '<table><thead><tr><th>', '| '), '</th></tr></thead><tbody>', concat(' |',decodeUriComponent('%0A%0D'),'|-----------|:-----------:|',decodeUriComponent('%0A%0D'))), '</th><th>', ' | '), '<tr><td>', '| '), '</td><td>', ' | '), '</td></tr>', concat(' |',decodeUriComponent('%0A%0D'))), '</tbody></table>', '')

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard