Power Platform: Print selected data table record to PDF file from PowerApps using Power Automate

If you see someone without a smile today, give ’em yours 🙂

.

Hello Everyone,

Hope you all are doing well.

Today in this article I am going to discuss about how to print selected data table record to PDF file from PowerApps using Power Automate.

We have good number of articles on Power Platform, please have a look.

https://knowledge-junction.in/category/technology-articles/power-platform/

So without getting late, lets get started.

Requirement

Having a dashboard screen with data table control and with all required filter options is a very common use case in PowerApps app. For every process such dashboards are required so that users can view and manage the records. Creating PDFs from the data sources is a standard requirement in many cases. For instance, getting data from SPO list or getting from Power Apps, generating pdf file.

Note : The HTML content cannot be greater than 2 MB for this PDF generation to work. This is the limitation of the Create File action for the ‘One drive for business’ connector. 

Solution

There is no direct connector in PowerApps to print the data to a pdf file, so we must trigger a FLOW from PowerApps and generate the PDF file in OneDrive or SharePoint and respond back with URL of the generated file.

Introduction:

The Errors app is used by people at an office to print the selected record in PDF. They open the app to the Error details screen, click on print to download and then open the PDF file.

Setup the SharePoint list

  • Create a new SharePoint list called Errors with the following columns:
TitleSingle line of text
Error fromSingle line of text
Error messageMultiple lines of text
CauseMultiple lines of text
ResolutionMultiple lines of text
SeverityChoice
PrintSingle line of text
fig: SharePoint list site columns
  • Include this data in the list.
fig: SharePoint list with data
fig: SharePoint list with data

Insert a table to display information in the app.

  • Open Power Apps Studio and create a new app from blank. Place a label at the top of the screen showing the title.
PowerApps title
fig: PowerApps title
  • Add the Errors SharePoint list as a datasource.
PowerApps datasource
fig: PowerApps datasource
  • Then insert a data table with and update the Items property to ‘Errors’ to show the list of error details.
PowerApps data table
fig: PowerApps data table

In data table columns, made the Print column as hyper link to download the respective record details in PDF.

fig: PowerApps hyper link
fig: PowerApps hyper link

Creating the print PDF flow.

  • Now we are ready to make the flow to print the errors table selected data to a PDF file. Go to the Action tab and select Power Automate. Then click create a new flow.
fig: Create new flow
  • Refer to the below screenshot to understand the steps used in FLOW -> Taking filter values as parameters from PowerApps.
Flow taking item id
fig: Flow taking item id
  • Use the varItemID variable output/result as input to Get Items as shown below -> Use compose action to generate tabular data, add whatever columns we want to print in PDF file.
fig: Flow – Get item
fig: Flow – Get item
Flow – Compose data
fig: Flow – Compose data
  • Use OneDrive create file action to create a html file, then use convert file action to convert the html file to the PDF file.
Flow – Create and convert html file
fig: Flow – Create and convert html file
  • Use OneDrive create file action to create a PDF file, then use create share link by path action to generate the PDF file URL, respond back this URL to PowerApps.
Flow – Create and download PDF
fig: Flow – Create and download PDF
  • At last, to print the selected record data to PDF by its hyperlink. Select the Print column and apply the below formula on its OnSelect property as:

Concurrent (Notify("Working on it...", NotificationType.Information), Set(pdfFileURL, PrintPDF.Run(tbl_Errors.Selected.ID).fileurl));Launch(pdfFileURL);

PowerApps print column OnSelect property
fig: PowerApps print column OnSelect property
  • We have triggered a FLOW on print of a record. If we see the Print column click code, then we have used Launch function to download the PDF file for end user.
  • This is how the selected data looks in the PDF file, the user can easily save/print it as PDF file and do the analysis.
PDF file
fig: PDF file

.

Hope this article will help us to print the selected data table records to a PDF file from PowerApps using Power Automate.

Also get my article updates on my social media handles.

LinkedIn – https://www.linkedin.com/in/khasim-shaik-8784a1232/

Twitter – https://twitter.com/KhasimShaik2009

Facebook – https://www.facebook.com/profile.php?id=100078255554660

Thank you for your support, will catch up with new article soon.

Keep learning and keep sharing.

Have a great day.

Thanks.

Khasim Shaik

SharePoint & Power Platform Developer at OS InfoTech

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: