Pragmatic Works Nerd News

Save multiple attachments and files from Microsoft Forms to a SharePoint list with Power Automate

Written by Jonathon Silva | Sep 13, 2024

In this tutorial, Jonathan Silva from Pragmatic Works walks you through the process of saving multiple attachments from Microsoft Forms to a SharePoint list using Power Automate. This approach differs slightly from handling single attachments, and Jonathan provides a detailed explanation of how to adjust your workflow to accommodate multiple file uploads.

 

Overview: Single vs. Multiple Attachments

If you’re already familiar with storing a single form attachment into a SharePoint list, you’ll notice that handling multiple attachments requires a few additional steps. In the original workflow for a single attachment, the process is straightforward: you capture the form response, retrieve the attachment, and store it in a SharePoint list. But when allowing users to upload multiple attachments, you need to adjust your flow to loop through and store each file individually.

Step 1: Initializing the Attachment Array

To begin, create a copy of your existing flow. This new flow will be used to handle multiple attachments:

  • Start by initializing a variable after the Get Response Details action. This variable will be an array that stores the attachments.
  • Go to Add an Action and select Initialize Variable.
  • Name the variable (e.g., VAR Attachments Array) and set the data type to Array. Leave the value field blank for now.

Step 2: Checking for Multiple Attachments

Next, you need to check if there are multiple attachments in the form response:

  • Add a Condition Control to evaluate whether the array of attachments is not equal to null.
  • In the condition, use the JSON expression to convert the attachment question's responses into JSON format. This ensures that Power Automate can process the attachments correctly.
  • If the array is not null, proceed to loop through each attachment.

Step 3: Looping Through and Appending Attachments

Now that you've confirmed the presence of attachments, it's time to loop through and append each one:

  • Add an Apply to Each control, which will loop over the JSON array you created in the previous step.
  • Within this loop, add an Append to Array Variable action. This appends each attachment to the array variable you initialized earlier.
  • Use the item() function to reference the current attachment within the loop.

Step 4: Storing Attachments in SharePoint

With the array of attachments now properly formatted, you can update your flow to store them in SharePoint:

  • In the Create Item action, update the attachment field to reference the array variable instead of the original attachment question.
  • This change ensures that each attachment is added to the corresponding item in your SharePoint list.

Testing the Workflow

After saving your flow, test it by submitting a form with multiple attachments:

  • Submit a form response with several files attached.
  • Check the SharePoint list to confirm that all attachments have been stored correctly.

Alternative Approaches

While this method is effective for many use cases, there are other ways to handle file attachments in Power Automate. For example, you could use a Canvas App to manage attachments more dynamically or explore other Power Automate features for more complex scenarios.

Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Microsoft Forms, SharePoint, Power Automate and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.