Microsoft Forms – Getting attachments from group forms

In my previous article I wrote about retrieving attachments from Microsoft Forms. The previous article covered forms that were linked to an individual, however if it is a group form the files are stored in the Document Library on the SharePoint site for the group instead of the form creators OneDrive. As a result of the different file location the process needs to be changed slightly.

To see how to get attachments from personal / individual forms please see the following link


In this article I will run through how to save the attachments from the Document Library on a SharePoint site.

Part 1: Setting up the form

In Microsoft Forms, go to Group Forms and select New group form

Then add the questions that you need to the form, including one with as a File Upload question which can be found in the drop down for the question types

Part 2: Setting Up the Sharepoint List

Depending on the information you want to capture from your form will depend on what columns you add to you SharePoint list

I have a SharePoint list set up called Issues and is used for capturing information about Defects or repairs for buildings

Part 3: Setting Up Power Automate

Once the form and SharePoint list are setup you are now ready to create the flow / automation using Power Automate.

In order to create the Flow you need to go into Power Automate and select Create. And since we want this process to happen automatically we will need to select Automated Flow

3.1 Setting up the trigger

The next step is to add a trigger, which in this case we will use the “When a new response is submitted”

Normally when working with Forms you can select the form from the Dropdown list of available forms in the Form Id field, however when working with Group Forms you may need to enter the Form ID as a custom value.

In order to get the Form ID you will need to go back to the form and copy the formID parameter from the URL

And paste it into the Form Id field after selecting Custom Value

We will then need to add the “Get response details” action and paste the Form Id into Form Id field again.

3.2 Creating Item in SharePoint

Once we have retrieved the data from the Form we can use the “Create Item” action for SharePoint. We will need to create a new item before we look at adding any attachments

Depending on the list you have these fields my vary.

3.3 Using the attachment data from the submitted form

The File Upload question will return details about the files uploaded in a JSON string. This is due to the type of information been returned for the uploaded files.

In order to be able to use the information about the files uploaded, you will need to use the “Parse JSON” action, this will convert the string into a useable array of objects, including the:

  • Name of the file
  • Link to the file
  • Id of the file

The “Parse JSON” action requires the schema of the JSON to be able to interpret it, however we don’t need to work this out manually.

If we add a “Compose” action and pass in the results from the File Upload question we can then run a save and run the flow, submit a response in the form and the “Compose” action will provide us with the JSON returned

Passing the response to the file upload question to the Compose action
Results of Flow been run

We can then copy the value from the Outputs field. Then go back to editing the flow.

We can then add a “Parse JSON” action and use the Generate from sample button and paste the Outputs value that we just copied and this will generate the JSON schema for us.

“Parse JSON” action

Notes:

  • Once you have the Schema setup for the “Parse JSON” action you go back and remove the “Compose” action from above
  • If there is a chance that an attachment may not be added you can add a condition to see if the response to the file upload question is blank.
  • The JSON will return an array even if there is only one matter the number of attachments

3.4 Getting file content

This is the main step that is different with Group Forms. If you are using Personal Forms then you can use the “Get file content” for OneDrive action, however with group forms the files are stored in the Document Library for the SharePoint site linked to the group.

Given that the “Parse JSON’ returns an array we will need use an “Apply to each” action and pass in the results from the “Parse JSON” action.

Then we can add the “Get file content using path” action for SharePoint.

3.5 Adding the attachment to the SharePoint list item

Once we have the file content we can use the “Add Attachment” action for Sharepoint to add the file to the previously created SharePoint item

Part 4: Wrap Up

That’s it, we should now be able to save and test the flow and see the information submitted through a Group Form in a SharePoint list, with any attachments.

I’ve included a screenshot of the entire flow below

About: Gareth


16 thoughts on “Microsoft Forms – Getting attachments from group forms”

  1. Hi Gareth,
    This has helped me greatly. Note that I am not experienced with Flow.

    What I am trying to do not is take what you have done and insert my attachments in to an email.

    If I add the “Send and email” action in to the “Apply to Each” Condition then I get multiple emails with one attachment each. If I move the “Send email” action out of the condition then I assume that I need to find a way of grabbing the file content and adding in to variable but I can’t get it happening.

    If you have any clever ideas, it would be greatly appreciated.

    Thanks in advance

  2. Hi Gareth,
    My step is failing at the Get content file path, its saying bad gateway status 502, the url is correct and i’m using the link option
    {
    “error”: {
    “code”: 502,
    “source”: “flow-apim-europe-001-francecentral-01.azure-apim.net”,
    “clientRequestId”: “ce6452fb-97a3-48bd-a51b-b1d36a9f191f”,
    “message”: “BadGateway”,
    “innerError”: {
    “status”: 500,
    “message”: “SiteId mismatch\r\nclientRequestId: ce6452fb-97a3-48bd-a51b-b1d36a9f191f\r\nserviceRequestId: ce6452fb-97a3-48bd-a51b-b1d36a9f191f”
    }
    }
    }

    Any ideas why?
    thanks
    Kathryn

  3. Hi Gareth,

    I’m having an error “File not found” when executing this flow and it is trying to get file content with path. Could you help me?

    Thanks

    1. Try Using the file path by accessing the folder structure to the right, then delete the file path at the end and change it to the JSON variable Name

      ie. Shared documents/Apps/Microsoft Forms/FORM NAME/QUESTION NAME/JSON Name Variable

  4. Hi Gareth, Thanks for this post – really helpful!

    Just a quick question – the “get file content using path” action does not if the file is a docx or xlsx file. It does however work with pdf files. Any suggestions? Thanks again!

    1. Try Using the file path by accessing the folder structure to the right, then delete the file path at the end and change it to the JSON variable Name

      ie. Shared documents/Apps/Microsoft Forms/FORM NAME/QUESTION NAME/JSON Name Variable

  5. Also experiencing the issues Blair and Laura have mentioned – tried shortening the link (removing &action=default&mobileredirect=true from the end) and it still failed. Any suggestions would be appreciated!

  6. Hi Gareth, thank you for this tutorial. Do you know if we are able to save multiple attachments from different questions on Microsoft Forms onto the SharePoint list?

  7. HI Gareth,

    No one could help me on the forums, maybe you have the answers:
    So after creating the MS Forms with an possiblity to upload a file, I will receive after a week the following error: “Failed to upload your file”. While my attachment is compliant with the allowed file types and below the maximum upload capacity.

    What could the problem be?

    1. Hi Djarano
      I’ve done some further testing to try and replicate the issue the only thing I can think of it could be related to file names. Is there a possibility that it could have the same name as another file?

  8. This does not work if you have attached office documents like for example an excle file.
    The link is not valid and you get a 404
    It is better to use the Onedrive get file content action and use the following input for the file field: driveId.id
    That works, and, yes indeed, for group forms.

Leave a Reply

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