Tuesday, 19 November 2019

Export PDF in Power Apps and Power Automate (MS Flows): Approach 1

In this blog, we will be exporting the List Item details into the PDF document with a button click. This approach is based on the use of both PowerApps and PowerAutomate.

In this scenario, a customized PowerApps form is there that is used to display data coming from the SharePoint list, and a button will be present on click of which users can export content into the PDF.

Create Flow

Complete flow with all actions


1. Open the flow, click on the Create option, search for "PowerApps", and select the option "PowerApps button" which triggers the flow on button click.


2. Add the "Initialize variable" action.
Enter the required values: – Name, Type and Value. To initialize the value, click on "See more".

Now click on the option "Ask in PowerApps"; it means the value will come from PowerApps form when flow is called as a parameter.

Select and add the initialized values. Similarly, create a new variable. Filename and initialize.

Now create the FileFullname variable. To initialize the value, select the Expression tab and concatenate the value of the filename variable with the .html file extension.

Similarly, create a new variable, CurrentUser and initialize.

3. Add "Create File" (OneDrive for Business) action.
Click on the Folder icon present in the Folder Path textbox. Browse the library and select the folder under which the HTML file will be saved and later converted to PDF.

Set the variables initialized above for File Name and File Content.

4. Add the "Create file using path" (OneDrive for Business) action.
Click inside the File Path textbox, and a callout will open. Select Path value from the Create file in OneDrive group under Dynamic content. Set PDF as the Target type.
Note: Create file OneDrive is the previous action, and these are all the outputs of it.

5. Add the "Send an email (V2)" (Office 365 Outlook) action.
Provide the required value for this as shown below.


Modify PowerApps Form

1. Open the list where Export PDF functionality needs to be implemented. Click on "Customize forms" to open PowerApps.

2. Add a new screen and add an HTML text control to it.

3. Add the HTML content with dynamic values as shown. The content will be added in double quotes.


4. Add a button for "Export to PDF" functionality. On the button, attach the flow.
    a. Select the button.
    b. On the Action tab, select Flows.
    c. All available flows will appear; select the required one.
    d. Choose the "OnSelect" option to RUN the flow and pass the required parameters.
    e. Save and Publish the PowerApps.

5. Open the display form and click on the "Export PDF" button.

6. The exported PDF will be sent to the current logged-in user's email..

Check the final exported PDF here


🚀 "Happy Coding" 🚀

1 comment:

  1. Good one, it helped me and it works
    appreciated!

    ReplyDelete