Muhimbi Convert a List Item, including all attachments, to PDF using Flows.

A few months ago, I wrote a blog which Merges all the documents within a document Library into Single PDF. In this blog we will use the same Merge action to convert a List Item, including all attachments, to a single PDF.

Prerequisites:

Before we begin, let have a look at the Final Flow:

FlowOverview

So now lets start building the Flow.


Step 1: Add the Flows Trigger action for SharePoint “When an item is created and add the “Site-Address” and “List Name“.

Step 1(When an item is created).png


Step 2: Add the “Convert HTML to PDF” Muhimbi Action and configure the fields with reference to the screenshot below.

For more details on “Convert HTML to PDF” see: http://blog.muhimbi.com/2017/10/converting-sharepoint-online-pages.html

Step 2(HTML action).png

Note: In SharePoint Online it is possible to display Lists and Libraries in Modern or Classic mode. The Modern View is undergoing constant change (by Microsoft), as a result, we currently only support the conversion of pages displayed in Classic View. Some Modern View pages will convert fine while others don’t.

The workaround for Converting Modern list view items would be to look-up the list item data in Power Automate(Microsoft Flow) and use the captured data, enrich it with HTML, and Convert it to PDF. For more details have a look at the article.


Step 3:  Add the SharePoint “Create file“, SharePoint action and Configure it with reference to screenshot below.

“File Name”: triggerBody().pdf (output from step 1). The Formula is triggerBody()?[‘ID’].

“File Content”: Processed file Content(output of step 2).

1.png


Step 4: Add a “Condition” in Flows and Configure it with reference to screenshot below.

Has attachments : Is the output of Step 1 “When an item is Created”

Condition “is equal to” true

Step 4(Condition)


Step 5 and Step 6: 

If yes, i.e. if the items has attachments, we need to do another 7 steps.

If no, we need to do Nothing 🙂.

Step5-6(yesno)


Step 7: Add the Get attachments SharePoint action.

Be very careful when selecting, the “Id” it should be CAPITAL “ID”, if you don’t see the ID in the Output from Step 1 “When item is created” then use the following Formula triggerBody()?[‘ID’]

Step 7(Get attachments)


Step 8: This is second and the most important Part of this Flow.

Step 8loop.png


Step 9: Add a “LOOP” in the Flows.

Apply to each, Select an output from previous step: “Body“(Output of Step 7, “Get attachments).

loop.png


Step 10: Add the “Get file content using path” SharePoint Action and get the file content of the file we have created in Step 3. Configure the action with reference to the screenshot below.

The File Path: triggerBody().pdf (output from step 1). The Formula is triggerBody()?[‘ID’].

2


Step 11: Add the SharePoint Online “Get attachment Content Action”.

Id: “ID” it should be CAPITAL ID“, if you don’t see the ID in the Output from Step 1 (When item is created) then use the following Formula triggerBody()?[‘ID’]

File Identifier: “Id” is the output of the “Get attachments” action (Step 7)

Step 10(Get attachment content).png


Step 12: This is where it gets a little tricky.

Source File name -1: triggerBody().pdf (output from step 1). The Formula is triggerBody()?[‘ID’].

Source file Content-1: “File Content” output of Step 10 “Get file content using path.

Source file name -2: Display name output of Step 7 output of “Get attachments”.

Source file content-2: “Attachment Content” output of “Get Attachment ContentStep 11.

3


Step 13: Add the SharePoint “Create file“, Flows action and Configure it with reference to screenshot below.

“File Name”: triggerBody().pdf (output from step 1). The Formula is triggerBody()?[‘ID’].

“File Content”: Processed file Content(output of Step 12).

4.pngHappy Converting 🙂 …

Related Article: For details about how to convert a list item, including attachments using Workflow, to PDF see https://support.muhimbi.com/hc/en-us/articles/228089307-Convert-a-List-Item-including-all-attachments-to-PDF

One thought on “Muhimbi Convert a List Item, including all attachments, to PDF using Flows.

  1. Excellent post. I was checking continuously
    this blog and I’m inspired! Very helpful info specially the ultimate section 🙂 I care for such info much.
    I was looking for this particular information for a long time.
    Thanks and best of luck.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s