MS Forms – Collecting attachments from anonymous users
MS Forms is an excellent and very easy-to-use tool. As a counterweight, the forms implemented with it cannot be edited much. It’s not the best form tool out there, but it’s good enough for most needs. Especially considering its good points:
- Price (included in M365 licenses)
- Easiness of integrations (Power Automate with 1100+ connectors)
However, one of its shortcomings is often encountered. The respondent can attach attachments to the answer only if the form has been published for the organization’s users. With anonymous users, you cannot attach files.
However, we would also like to collect attachments from anonymous users. Next, we go through how this can be implemented.
Gathering data with MS Forms
First, we make a simple form with MS Forms that anyone can use to report an incident. The form asks if the person filling in wants to submit attachments related to the incident.
In the form’s confirmation message, we inform the user about the next step. If s/he wants to add attachments to the incident, s/he will soon receive an email.
Option 1 – Sharing the Document Library folder
We need a place where the attachment files are collected. A document library (MS Forms Attachments) is created on the SharePoint site.
After this, a flow is created. Flow triggers when the user submits the form (Trigger: When a new response is submitted). As a first action, we get response details.
Next, we check if the user also wanted to deliver attachments (Condition: I like to deliver attachment(s) related to the incident = Yes).
If this is the case, a new folder will be created in the document library with the name of the user’s e-mail address supplemented with the identifier of the response.
Then we create a sharing link to the created folder. Use of the link must be allowed for everyone (Link Scope: Anyone with the link, including anonymous). We also set the validity period for the link (Link Expiration).
With the created link, the respondent can drop her/his file into the SharePoint document library. In the folder created for her/him.
Finally, this link is sent to the respondent by e-mail.
SharePoint site settings
By default, unauthenticated users cannot access document libraries. Even if the link was created to them with all permissions. Access must still be allowed separately. The setting (External file sharing) is made from the SharePoint administration center and is site-specific.
How does it work in practice?
We will send the information about the incident using the form.
Flow creates a new folder in the document library.
After that, flow sends the person concerned a link to add documents.
This allows the user to add attachments. He sees the name of the SharePoint site, the document library used, and the folder created for her/him.
Option 2 – Requesting files
Files can also be requested using SharePoint’s “Request files” feature.
The difference from the previous method is that the end user can only see the description you wrote in the request. S/he does not have visibility into the actual document library.
This method also requires allowing file sharing to unidentified users on the SharePoint site.
The request cannot be made using Flow’s standard actions, but Nick DeCourcy showed in his YouTube video how to create a link using the SharePoint API.
Let’s replace the Create sharing link for a file or folder action from the flow we just made with the Send an HTTP request to SharePoint action.
The body we use in the action is the following:
{
"request":{
"createLink":true,
"settings": {
"allowAnonymousAccess":true,
"linkKind":6,
"expiration": null,
"restrictShareMembership":false,
"updatePassword":false,
"password":"",
"description":"Thank you for you response. Please drop your attachments to here",
"role":8,
"applicationLink":false,
"limitUseToApplication":false
}
}
}
The action returns a long JSON message.
The essential one (the link to be sent to the user) can be found most easily with the following formula.
body('Send_an_HTTP_request_to_SharePoint')?['d']?['ShareLink']?['sharingLinkInfo']?['Url']
Finally, we will update the link in the email to this new one.
Ready!
How does it work in practice?
The person filling out the form will still receive an email after filling out the form. But the link opens on the following page.
The user selects the files and uploads them to the document library.
The user cannot browse the contents of the folder. He can only drop files there.
The user who generated the request will be notified whenever new files have been uploaded.
Linking files to answers
Now we can collect the attachments from the respondents. How we can link attachments to the submitted form?
The easiest way is if the answers are saved (using flow) somewhere (like Dataverse or SharePoint). At the same time, we can store a link to the attachments folder as well.