• Yash Agarwal

Working with Files on MS Forms Group Form in MS Power Automate

In this #PowerShot I will show you how to use the 'Upload File' option on MS Forms group forms and then access that file to perform further operations using MS Power Automate.


The upload a file type question on MS Forms group form, first creates a folder with the name of the Form (or quiz) in SharePoint document library of the site the group form is created for. All the files that are uploaded as a part of this form will be then saved in that folder.


While creating the 'Upload File' question on the form, you can provide restrictions to the number, size and extension of the files that the responder can upload. '


Here is the link to another blog post that shows you how to handle files on regular forms (forms that are not group forms)


Let's Get Started!


In this demo, we will create a simple quiz type form with two questions, one that allows the responder to add text data and another that allows the user to upload a file. We will then trigger a Flow in MS Power Automate when a user responds to this form and then access the user responses to populate an email, add the uploaded file as an email attachment on a 'Send an Email' action.

MS Forms


For a simple demo, I created this quiz type form that has two questions.


Q1: Enter Name.


Q2: Enter comments (that allows responder to enter some text on the form).


Q3: Upload a file.

MS Power Automate

Step 1: Trigger: When a new response is submitted using the MS Forms trigger. I cannot directly select the group form so I will pass the ID of the group form here as a custom value.


Step 2: Action: Get response details: to get the response details from the submitted form. As I cannot directly select the group form, I will pass the ID of the group form here as a custom value and select the response ID for this action.


Step 3: Action: Parse JSON: This action is a very import one here as the response of the form contains the Upload File questions' answer in the form of a string. This string is basically an array of objects that contains the file name, link to item and such details. The schema used in the parse JSON action is:

{ "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" ] } }

Step 4: After the Parse JSON action, intialize a variable of type array to store all the files.


Step 5: Control: Apply to each: For each item in the body of the file question,


//Start Loop


Step 6: Action: Get file content using path: to get the file content of individual items from SharePoint document library. Select the appropriate SharePoint site/ Group where the form is and then navigate to the path.


Step 7: Action: Append to array variable:


{

"Name": "@{items('Apply_to_each')['name']}",

"ContentBytes": @{body('Get_file_content_using_path')['$content']}

}


This appends each individual file to the variable and we are using the "ContentBytes" key to store the file content.


//Loop Ends

Step 8: Action: Send email action: select the array input and then pass the above created array in the attachments field

In this article we saw how to access files uploaded on an MS Forms group form from MS Power Automate and send it as an email attachment. Similar approach can be used when trying to record the form responses on SharePoint lists or other such data sources and the files can be accessed from the SharePoint folder.


I hope you found this interesting and it helped you!

Recent Posts

See All

Working with Throttling Limits in Power Automate

In this #PowerShot, I will show you how to better handle throttling limits for API requests actions, connectors and flow runs in Power Automate. Let's Get Started Connectors in Power Automate have a s

SUBSCRIBE VIA EMAIL

Yash Agarwal

  • Black LinkedIn Icon
  • Black Twitter Icon
  • Black Facebook Icon
  • Black Instagram Icon
  • Black RSS Icon

© 2019 By the Devs