Microsoft Forms being able to upload and handle individual files of up to 1 GB is a really nice feature of the software. Considering PowerApps file upload limit is 50 MB, Forms is a nice simplified alternative to consider when deciding which piece of software to use in different situations. Being able to get attachments from Microsoft Forms and upload to SharePoint automatically is a really nice compliment as well. By default when users upload an attachment via a form it gets saved to OneDrive in this location:

Files > Apps > Microsoft Forms > "Form Title" > "Question Title"

However in many situations, we’ve found that users want the file to be stored in SharePoint in a certain document hierarchy along with the Form response. So we built a simple Power Automate workflow to handle it. There are a few quirks but we will call them out as we walk through it:

Create a Document Library in SharePoint

Create the document library to store the files from Forms inside of SharePoint. Every Form question should be mapped to an appropriate SharePoint column so that there is one question per column. This is important when building out the Power Automate workflow later.

Build the Workflow

  1. Trigger the worfklow off of the Microsoft Forms trigger
    “When a new response is submitted” and pass in the Form that you want to store.

2. Add an action called “Get Response Details” from the Microsoft Forms connector. This is necessary because you don’t get all of the form responses through the trigger. Pass in the Response ID from the trigger action.

3. Now you have all of the form response details but unfortunately we can only access the Uploaded Attachments piece of dynamic content but are unable to get any details about the attachments. In order to get the attachment details we can just parse a little JSON. Add a “Parse JSON” action, pass in the “Attachments” dynamic content from the “Get response details” action, and paste in the schema below:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "link": {
                "type": "string"
            },
            "id": {
                "type": "string"
            },
            "type": {},
            "size": {
                "type": "integer"
            },
            "referenceId": {
                "type": "string"
            },
            "driveId": {
                "type": "string"
            },
            "status": {
                "type": "integer"
            },
            "uploadSessionUrl": {}
        },
        "required": [
            "name",
            "link",
            "id",
            "type",
            "size",
            "referenceId",
            "driveId",
            "status",
            "uploadSessionUrl"
        ]
    }
}

4. In order to handle form submissions that have multiple attachments we need to loop through the body of the JSON response. Add an “Apply to Each” action and pass in the dynamic content called Body from the “Parse JSON” action.

5. Inside of the “Apply to Each” action add “Get file content using path” and
“Get file metadata using path” from the OneDrive connector. This is important because while we got the file details from parse JSON, now we have to go get the content of the file and the file metadata from OneDrive. The File Path is written out below the image:

/Apps/Microsoft Forms/*Name of Form*/*Name of Question*/name(dynamic content from Parse JSON)

6. Now we have all of the information we need to actually recreate the file inside of SharePoint. Add a “Create File” action from the SharePoint connector. Use the appropriate Folder path and Site Address, and then pass in the Name piece of dynamic content from the “Get File Metadata Using Path” action and File Content from “Get File Content Using Path”.

7. Now we just need to add the Form responses to the SharePoint columns that were created. Add the “Update File Properties” action from the SharePoint Connector and add the dynamic content for your Form questions to the appropriate SharePoint columns.

Summary

This blog post walked through how to grab attachments from Microsoft Forms and upload to SharePoint via Power Automate. Please let us know if you have any comments or find another way to accomplish this! If you liked this blog post, check out other posts along the same lines:


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *