Blog Post

Converting and Archiving InfoPath Forms to PDF using Microsoft-Flow

Clavin Fernandes
Illustration: Converting and Archiving InfoPath Forms to PDF using Microsoft-Flow

This article is based on a post Clavin Fernandes made to his personal blog, the information in it is used with his permission. Thank you Clavin!

Ever since Microsoft announced the retirement of InfoPath, people responsible for archiving forms and maintaining their accessibility have been busy searching for alternatives to InfoPath.

Luckily, we’ve been busy with this as well!  So, we started with a previous post and decided to update it here using some of the new functionality available with Microsoft Flow.

Using Flow to convert and archive InfoPath forms is a bit more involved than doing the same in SharePoint, as InfoPath uses two files to create a single form, an XML (data) file and an XSN (template) file. In this post we will create a simple Flow that is triggered whenever a form is added to a folder in a SharePoint Online Library. Once added, the form is automatically converted to a PDF stored in a OneDrive for Business folder.

This is just an example, it can easily be adjusted to use different file services (e.g. the trigger can be for files uploaded to OneDrive, Box.com, DropBox, Google Drive or can even be used to Migrate your SharePoint On-Premise InfoPath Forms to SharePoint Online etc).

Before we begin:

Create the Flow

From a high-level perspective, the Flow looks as follows:

Note: Converting an InfoPath form is similar to converting any other document type using Muhimbi’s Flow Actions, but - as it is needed during conversion - you need to pass in the XSN file (the file content, not the URL to the file) alongside the XML file.

The Flow consists of the following elements:

  • Trigger - When a file is created in a folder: Specify the path to the SharePoint Online folder to monitor for new files. (To trigger a Flow for files created anywhere in a Library, use the ‘When a file is created (properties only)’ trigger, and retrieve its content using Get file content.)

  • Get file content: Specify the path to the SharePoint Online location where the XSN has been published to. (By default it is stored in the Forms Folder, e.g. https://yourdomain.sharepoint.com/sites/Sitecollectionname/Library /Forms/template.xsn

  • Convert document: Insert the Muhimbi PDF Convert Document action, and fill it out as follows. (see the screenshot below for details):

    • Source file name:File name” the output from the “When a file is created in a folder” trigger.

    Source file content: “File Content” the output of the “When a file is created in a folder” trigger.

    Output format: PDF

    Template file: “File Content” the output of the “Get file content” action, which contains the InfoPath XSN file.

    Do not just pass the path to the XSN file into the Muhimbi Action as it doesn’t have the privileges to read that file.

  • Create file: Specify the path to the OneDrive folder where the converted PDF files are written to. Pass in the ‘Base file name’ field returned by the Convert Document action, making sure that it is suffixed with ‘.pdf’. In the ‘File content’ field pass in the ‘Processed file content’ returned by the Convert document action.

Voila- You’re finished!  Now, publish the Flow and then save an InfoPath form in the SharePoint Online folder to test the Flow. After a few moments a PDF file will appear in the OneDrive destination folder.

This is just a basic example. Please keep in mind that the Muhimbi PDF Converter also comes with facilities to convert files attached to InfoPath forms as well as choosing which InfoPath view or views to convert.

For more Microsoft Flow, Logic Apps & PowerApps Tutorials and Blog posts, see our Knowledge Base.

As always, if you encounter any difficulties, please feel free to contact our friendly Support Desk for any assistance you may require.

Author
Clavin Fernandes Developer Relations and Support Services

Clavin is a Microsoft Business Applications MVP who supports 1,000+ high-level enterprise customers with challenges related to PDF conversion in combination with SharePoint on-premises Office 365, Azure, Nintex, K2, and Power Platform mostly no-code solutions.

Explore related topics

Share post
Free trial Ready to get started?
Free trial