cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JMMurphy
Level: Powered On

powerapps flow to convert html to pdf - powerapps code is rendering as text

Hi

 

I've created a flow to convert html text  into a pdf (as per Shane Young's video).  The html includes powerapps code to bring in dynamic data from the selected item in a gallery. The html is working well in powerapps, however, when I bring it into flow the powerapps code renders as text in html and pdf.  The html file shows the formatting as expected but the PDF file does not, in fact one table is missing.  

 

So I have two issues:

 

1. How to get the html to show the data from Powerapps rather than the code (I've tried wrapping it in concat() but I haven't been able to make it work).

2. How to get the html formatting to render into pdf via flow properly.

 

The html code is as below:

 

"<html>
<head>

<style>
h{font-family:arial}
h1{font-family:arial}
h2{font-family:arial}
p{font-family:arial}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}


</style>
</head>

<body>


<h1>
"&Gallery2.Selected.srOverallRAG&"</h1>
<h1>"&Gallery2.Selected.Title& " "& Text(Gallery2.Selected.srReportDate,"[$-en-US]dd/mm/yyyy","en-GB")&"</h1>


<Table>
<tr>

<tr>
<th>Overall</th>
<th>Schedule</th>
<th>Cost</th>
<th>Resources</th>
<th>Business Readiness</th>
<th>Resilience</th>
</tr>
<tr>
<td>"&Gallery2.Selected.srOverallRAG&"</td>
<td>"&Gallery2.Selected.srScheduleRAG&"</td>
<td>"&Gallery2.Selected.srCostRAG&"</td>
<td>"&Gallery2.Selected.srResourcesRAG&"</td>
<td>"&Gallery2.Selected.srBusReadinessRAG&"</td>
<td>"&Gallery2.Selected.srResilienceRAG&"</td>
</tr>

</table>

<p><strong>"&Gallery2.Selected.srKeyMessage&"</strong></p>

<h2>Update And milestones</h2>

<p>text - update and milestones</p>

 

<Table>
<tr>
<th>Help Required</th>
<th>From Who?</th>
<th>Help required</th>
<th>From Who?</th>
</tr>
<tr>
<td>Help required1</td>
<td>From Who1</td>
<td>Help required3</td>
<td>From Who3</td>
</tr>
<tr>
<td>Help required2</td>
<td>From Who2 </td>
<td>Help required4</td>
<td>From Who4 </td>
</tr>
</table>

</body>
</html>

 

"

1 ACCEPTED SOLUTION

Accepted Solutions
JMMurphy
Level: Powered On

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

I found the solution: the CONCAT() in file content was the wrong expression to use.  I just changed this to  'CreateFileFileContent'. 

8 REPLIES 8
Super User
Super User

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

The reason why your data is rendering as text rather than values is that the context of that data is PowerApps, not Flow.  So Flow doesn't know how to interpret those values since they are out of scope.  You'll need to insert the actual values into the HTML text before you pass it to Flow for rendering.

 

For the HTML coming through as text, i suspect something about the HTML is invalid.  When you export the HTML to a file as Shane does does it render correctly as HTML in the browser?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

Hi @JMMurphy ,

Do you want to pass the HTML code value from your app to your flow?

 

Based on the needs that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. Based on the HTML code formula you provided, I think there is something issue with it. Please modify your formula as below:

 

"<html>
<head>

<style>
h{font-family:arial}
h1{font-family:arial}
h2{font-family:arial}
p{font-family:arial}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
</head>
<body>
<h1>
"&Gallery2.Selected.srOverallRAG&"</h1>
<h1>"&Gallery2.Selected.Title& " "& Text(Gallery2.Selected.srReportDate,"[$-en-US]dd/mm/yyyy","en-GB")&"</h1>
<Table>                          /* <-- Replace here with table rather than Table */
<tr>
<tr>
<th>Overall</th>
<th>Schedule</th>
<th>Cost</th>
<th>Resources</th>
<th>Business Readiness</th>
<th>Resilience</th>
</tr>
<tr>
<td>"&Gallery2.Selected.srOverallRAG&"</td>
<td>"&Gallery2.Selected.srScheduleRAG&"</td>
<td>"&Gallery2.Selected.srCostRAG&"</td>
<td>"&Gallery2.Selected.srResourcesRAG&"</td>
<td>"&Gallery2.Selected.srBusReadinessRAG&"</td>
<td>"&Gallery2.Selected.srResilienceRAG&"</td>
</tr>
</table>

<p><strong>"&Gallery2.Selected.srKeyMessage&"</strong></p>

<h2>Update And milestones</h2>

<p>text - update and milestones</p>

 

<Table>                                    /* <-- Replace here with table rather than Table */
<tr>
<th>Help Required</th>
<th>From Who?</th>
<th>Help required</th>
<th>From Who?</th>
</tr>
<tr>
<td>Help required1</td>
<td>From Who1</td>
<td>Help required3</td>
<td>From Who3</td>
</tr>
<tr>
<td>Help required2</td>
<td>From Who2 </td>
<td>Help required4</td>
<td>From Who4 </td>
</tr>
</table>

</body>
</html>

 

"

Note: Please make sure the open tag (e.g. <table>) and the close tag (e.g </table>) matched properly in your HTML code above.

 

More details about converting data from app into PDF file, please check the following video resources for help:

https://www.youtube.com/watch?v=IhE0-HumNNo&feature=youtu.be

https://www.youtube.com/watch?v=bfXV_GXc_JM

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JMMurphy
Level: Powered On

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

Hi @Pstork1 

 

Thanks for your reply. It makes sense but I'm having trouble how to work out how to render the code in powerapps as text to pass over to Flow. I've been trying concatenate and concat but they don't appear to work.  I am referencing only the selected record in a gallery.

 

I solved the issue with the HTML (thanks @v-xida-msft - in addition to the error in the table tag that you spotted one of the table row tags had come adrift).

Super User
Super User

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

Glad you got it working.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
JMMurphy
Level: Powered On

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

thanks but I'm still having trouble with it - I can't work out how to convert the code in powerapps so flow can treat it as text - I have tried using concatenate and concat but neither of them will work for me.

Community Support Team
Community Support Team

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

Hi @JMMurphy ,

Actually, the HTML code in PowerApps app is recognized as Text value. You could pass the HTML text to the flow directly.

 

You could consider add a HTML text control within your app, then set the HtmlText property to the HTML code that you mentioned. Then within your Flow connection formula, you could type the following formula as argument:

'FlowName'.Run(HtmlText1.HtmlText, ...)

 

Within your flow, you could created a HTML file based on the passed HTML text value using "Create file" action of OneDrive for Business connector or OneDrive connector, then use the "Convert file" action of OneDrive for Business connector or OneDrive connector to convert the HTML file content into a PDF file content, then based on the converted PDF file content, you could create a PDF file.

 

Please consider check above video resources I provided, then check if it could help in your scenario. Within the video resource, you could learn how to use Concat function to concatenate column values from a Table.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JMMurphy
Level: Powered On

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

thanks but I watched the video, created a htmltext control, added the html and created the flow to create a html file and then a PDF before I posted the question. 

 

The flow is running but the powerapps code is showing as code and not as the result.  

I've used CONCAT('') in flow with the html from powerapps.

 

 

Here is an extract of the code which shows how powerapps code is placed in a longer string of html (have left the rest of the html out for clarity)

 

<h1>
"&Gallery2.Selected.srOverallRAG&"</h1>

 

 

This leads to this output in the HTML/PdF

"&Gallery2.Selected.srOverallRAG&"

 

Edited: I succssfully edited this formula by going to Action > Flow and editing it there rather than typing it directly into the formula bar.  I still haven't got it to run in Flow though.

The RUN formula which you suggest sort of works in that it shows the HTML strung together with the correct values rather than the Powerapps code however  powerapps underlines it in red and returns the error "Invalid number of arguments received: received 1, expected 0").  This is the expression which is triggered by the OnSelect property of a button control:  'PowerApp->Createfile'.Run(HtmlText1.HtmlText)

 

 

JMMurphy
Level: Powered On

Re: powerapps flow to convert html to pdf - powerapps code is rendering as text

I found the solution: the CONCAT() in file content was the wrong expression to use.  I just changed this to  'CreateFileFileContent'. 

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 306 members 5,093 guests
Please welcome our newest community members: