In this article, we’ll explain how to add Microsoft Forms attachments to SharePoint lists for use in Power Automate.
DocJuris’ auxiliary Flows are pre-defined templates of complex actions that you can import to your Power Automate environment and use as a “black box,” meaning that the complex actions are hidden and centralized. This allows you to:
- Perform complex actions without being concerned about how they work.
- Centralize standard practices so that you can re-use them in all your Flows.
- Use them and take advantage of DocJuris’ expertise and speed up your Flow development
If you’re starting with Power Automate, you’ll want to check out our Power Automate guide.
Microsoft Forms is a great way to collect user feedback or files, including PDF or Excel files. Still, it would be great to have those files inserted into SharePoint for safekeeping, especially if they are linked to a SharePoint list item. This article will cover how to do this using DocJuris’ auxiliary Flows, in order to automate the task of getting the files from Microsoft Forms and inserting them into Microsoft or SharePoint list items.
Installation
Step 1: Install the DocJuris Auxiliary Flows as an imported solution
You can refer to Installing DocJuris' Auxiliary Flows for further information about initially installing auxiliary Flows. The article will explain what auxiliary Flows are and how to import them to your environment so you can use them efficiently.
Step 2: You must add the flow you're creating to the solution
First, create a flow and save it. Next, find DocJuris Auxiliary Flows under the Solutions tab. Click DocJuris Auxiliary Flows and then click "Add Existing" -> Automation -> Cloud flow. Pick the flow you're creating and add it to the solution.
Overview
Our aux flow will help you transfer a list of attachments submitted via Microsoft Forms and add them to a SharePoint list item. As previously mentioned, we’ll be using it as a “black box”, meaning that we’ll use an action to call and add the files to SharePoint or Microsoft lists.
To demonstrate how it works, let’s look at a sample Microsoft Form that will collect the information from the user.
It’s a simple form; the key is that you can upload one or multiple documents and add all the questions you want your user to answer. The Flow will get all the information submitted in the form, not just the attachments, but for this article, we’ll focus on the attachments side of the Flow.
Find the Flow
As mentioned before, you must import the auxiliary Flow to your environment before using it. You can do this by following the instructions on Installing DocJuris' Auxiliary Flows. You must also add the flow you're creating to the solution!
You must use the “Run a Child Flow” action to run an auxiliary Flow. You can find that action in Power Automate and select “Built-in” followed by “Flows.”
You can then find the “Run a Child Flow” action as follows: Click Flows, and under Actions, select “Run a Child Flow”.
Here’s what it looks like:
Search for the auxiliary Flow by pushing the dropdown arrow to open the “Select a flow” menu.
The “Child Flow” field will contain the file name you defined at the time of import. Your name can be different than the one in the example above.
The auxiliary Flow’s fields
Now that we found the auxiliary Flow, let’s check each field we need to provide. All fields are required. The Flow is designed so we can only insert it into one SharePoint list item at a time. To insert multiple items or SharePoint lists, you must build other “Run a Child Flow” action calls with the corresponding fields from each list or item. In the same line, if you want to separate the attachments per SharePoint list items, then you need to parse the “attachments” field to contain only the files you want to be inserted. We strongly recommend not doing this, since any mistake in parsing the “attachments” field may result in the auxiliary Flow not working, so proceed with caution.
Attachments
Since we want to insert Microsoft Forms attachments, it’s only logical that we’ll start with them. To fill in this field, you only need to provide the raw value you get from Microsoft Forms. You can use the “Get response details” action as follows:
Depending on your Microsoft Forms, the name presented may be different. Notice that the form’s name is the same as displayed in Power Automate.
Here’s what it looks like in Power Automate.
There’s no configuration, conversion, or parsing needed. You can provide the value “as-is,” and DocJuris will take care of the rest.
Site to import
Now that we have the attachments to load, we need a site to load them on. Please note that the user running the Flow must have access to the site and the list; otherwise, the Flow will fail. A good test is to access the SharePoint site and list with the user running the Flow: if you can see the information and edit the fields, then your Flow will work.
For better results, you should provide the URL to the site only. For example:
https://<your domain>.sharepoint.com/sites/<your site name>/
You can clear everything after the site name, but if you don’t, DocJuris’ auxiliary Flow will try to find the site in the provided URL.
Finally, the auxiliary Flow will work for Sharepoint lists as well as Microsoft lists, so you can provide an Url as follows:
https://<your domain>-my.sharepoint.com/personal/<your email>/
You don’t need to provide more information in this field besides the one presented above, but as for SharePoint lists, the DocJuris system will do its best to find the required portion of the site in the provided URL.
List to Import
Now that we have a site, we also need a SharePoint list to import the information to it.
To do this, you only need to provide the list’s name, and you can get it directly on SharePoint as follows:
You don’t need to convert the list name in any way. DocJuris’ auxiliary Flow will do the required name conversion, if necessary.
Copy the name to the auxiliary Flow as follows:
Please be careful to paste the name as you find it in SharePoint, and don’t introduce unnecessary spaces before or after you copy the name.
List Item ID to Import
In the final site configuration, you need to provide the identifier for the list item to which you want to add the attachments. SharePoint generates and manages the IDs, and DocJuris cannot change them. All SharePoint lists contain this column, even if it’s not visible to you. If you don’t see the ID column, please access your list and press “+Add column”.
Next, select “Show/Hide Columns”.
Select the “Show/hide columns” option, select the checkboxes for ID and Title columns, and press “Apply”.
You will now see the column with “ID”.
Now that you have the ID column, you can select the item on which you want to insert the attachment.
Add the value to your auxiliary Flow as follows:
Please only insert the ID without any spaces and additional characters. It’s essential to provide a valid value so that the Flow will work. If the Flow fails, please check if the SharePoint with the provided ID is still present and was not deleted. Since SharePoint provides views, you may not see all elements, so please check a view with permissions and elements to ensure that the element exists.
Keep the original files' names
When the user submits a file in Microsoft Forms, it will keep its original name when storing the file. Names can be as diverse as the people creating them, so DocJuris’ auxiliary Flow provides a way for you to uniform the names. By selecting “Yes” the file will be renamed before it is inserted in SharePoint’s list as an attachment. The file name will be a random number to ensure uniqueness.
It’s important to know that SharePoint requires the names to be unique per item. For example, an item with ID 1 can only have a file attached named “File.xlsx”, but you can have elements ID 1 and ID 2 with files attached with the same name.
This feature will serve two purposes:
- Keep the file names under control and uniform since the files can have any name the user wishes. If multiple people have access to SharePoint, it may be a good idea to rename the file to keep the names under control.
- Avoid having issues while inserting the files in SharePoint due to the uniqueness constraint.
You can select the value by pressing the dropdown as follows:
The value is required, so be sure to provide a selection.
Remove existing attachments
If you’re running the Flows multiple times and don’t want to insert duplicated files, you may want to enable this function. The auxiliary Flow will remove all attachments for that item before inserting the new ones. This operation won’t replace or compare the files between the incoming and the existing, but it will replace all files that exist in the SharePoint list item. If you have ten files in the SharePoint list item and the user submits another file, the list will only contain one file after the Flow runs.
You can select the values by pressing the dropdown as follows:
The value is required, so be sure to provide a selection.
I don’t see the Attachments column in SharePoint
If you don’t see the attachments in your SharePoint list, not to worry: the Attachments column is always created when a SharePoint or Microsoft list is created, but it’s not always visible.
Here’s how to make the Attachments column visible.
First, access your list and press “+Add column”.
Next, select “Show/Hide Columns”.
Find the “Attachments” column in the dropdown menu. Notice that depending on SharePoint’s or your configurations, the names may be different.
Select the “Attachments” column and press “Apply”.
The column will now be visible.
Here’s what the SharePoint list will look like with the ID, Title, and Attachment columns visible:
Please note that DocJuris’ auxiliary Flow will work even if the Attachments column is hidden in some or all views.