Microsoft Forms provides us with a quick and easy way to create surveys, quiz’s etc. The response to these Forms can be saved in SharePoint list or can be sent over email using Microsoft Flow but how can we save the responses as a PDF in the SharePoint Online Document Library?
In this Blog, we will use the Muhimbi “Convert HTML to PDF” Microsoft Flow action to Convert the Microsoft Form response to PDF and save it in a document Library.
If you are working with complex controls(checkbox) and want to preserve your Forms layout then see blog post.
Please make sure the following prerequisites are in place:
- An Office 365 subscription with SharePoint Online license.
- Muhimbi PDF Converter Services Online full, free or trial subscription(Sign up).
- Appropriate privileges to create Flow.
- Working knowledge of SharePoint Online, Microsoft Flow and Microsoft Forms.
For this demo, we will convert the Sample Microsoft Form (below) to PDF.
From a High level our Flow will look like:
Add the “When a new response is Submitted” trigger action. It will trigger the flow when a new response is submitted.
In the trigger action specify the “Form Id” of the Microsoft Form.
- Add the “Get response details” action. This action retrieves a form response.
- Specify the “Form Id” of the Microsoft Form
- For the “Response Id” add the output “List of response notifications Response Id” of the “When a new response is Submitted” trigger action.
- This is where the real Magic happens. Add the Muhimbi “Convert HTML to PDF” action.
- Copy the HTML fragment provided below in the ‘Source URL or HTML’ area in the Muhimbi ‘Convert HTML to PDF’ action and then insert the various list fields in the appropriate places just before each line’s <br/> element.
<html> <body> <h2>Help us Improve</h2> Responders Email:<br /> Submission time :<br /> Feedback:<br /> </body> </html>
Use the “Create file” SharePoint action to write the PDF document to the SharePoint document library.
- File name: For this Demo, we will use “Feedback(Responder’s Email).pdf” (output variable of the “Get response details” action).
- File content: Processed file content the (output variable of the “Convert HTML to PDF”)action.
All done! Now it’s time to test our Flow.
- Open the link\URL for the Microsoft Form in the browser and submit a Form.
- The Flow will be triggered automatically and a PDF should be created in the SharePoint Document Library.
11 thoughts on “Convert responses from Microsoft Form to PDF”
I’ve followed your described method but I seem to have hit a snag. If a person submits more than one form response then their previous pdf-ed response gets overwritten in the SharePoint library. How do I overcome this? Any help greatly appreciated as I’m quite new at this.
A quick solution would be to add the UTC() Expression – Your formula would be
Another idea would be to generate a random GUID() – Reference formula –
Thanks for that, the random GUID() worked.
Sorry but one more question, my form has about 15 questions, with quite a few of them large text boxes. My issue is that the pdf created has none of the white spaces and line breaks in these longs paragraphs kind of making it hard to read and also decipher.
is there any way to retain the formatting from the original form response when converting it to PDF?
Im probably not the best person to answer but use the function in your code . Each creates a brake line
Thanks for this guide. I followed the directions and the flow ran, but created a .dms file vs .pdf even though I have the .pdf in the “File Name” field of the “Create File” step. Any thoughts?
Can you please drop an email to firstname.lastname@example.org, with the screenshot of the “Create file” action in the edit mode?
Thanks! that pointed me to where the problem was. An open parentheses and no .pdf. All fixed.
Hi I am facing a new issue. In the apply to each trigger I don’t find the dynamic expression List of Respondents ID –Can you help me with the way out
Wondering if there is a cleaver way to auto-magically create an HTML table for each answered questions with 2 columns the first for the question and the second with the answer. That way we can re-use the same actions for all of our Forms without having to explicitly create the HTML as in your example. I can get the JSON data but as you might be aware it only includes the question ID’s and not the actual question text. Thanks in advance.