How to send Microsoft Forms file uploads from multiple questions to an Approval workflow using Power Automate

 In this tutorial I show you how to create a simple Power Automate flow that will send multiple file uploads from multiple Microsoft Forms questions to an approval workflow.

This flow is in response to a question posed by a Tiago Santos de Araujo:

I need to upload attachments from different questions on forms and send all together in the same approval .

Comment on the post How to send Microsoft Forms file uploads to an Approval workflow using Power Automate

In the previous post I created a flow that accepted files uploaded from a Microsoft Form (an Application form). The uploaded files were then attached to an approval action. However the flow only worked with a single forms upload control.

We need a new flow that can work with multiple form upload controls. In this tutorial I show you how to create a simple Power Automate flow that will send multiple file uploads from multiple Microsoft Forms questions to an approval workflow. The scenario here is a cafe manager uploading a new menu each week via Microsoft forms and then being sent for approval to his or her boss.

The image below shows what is needed in the new flow The Weekly Menu Upload form requests the manager to upload four menus: breakfast, lunch, teatime (if you are British!) and dinner.

We need a new flow that can work with multiple forms upload controls
We need a new flow that can work with multiple forms upload controls.

The steps in this flow will be:

  1. A manager completes a Microsoft Form and uploads multiple files
  2. Get the user’s Forms response
  3. For each file upload control:
    • for each file that was uploaded – Get the filename and content (files are stored in OneDrive)
    • Note that the manager may upload zero, one, or multiple files for each question
  4. Create an Approval and add attachments to the approval action
Example Microsoft Form. The form contains four file upload questions.
Example Microsoft Form showing multiple file upload controls. There are four file upload questions for each of the menus: breakfast, lunch, teatime and dinner.

This Weekly Menu Upload form has been configured so that file uploads are optional. A limit of one file upload per question has also been set. However, the flow will still be able to handle multiple file uploads per question.

The form has been configured so that file uploads are optional and there is a limit of one file upload per question. However, the flow will be able to handle multiple file uploads per question.
The form has been configured so that file uploads are optional with a limit of one file upload per question. However, the flow will still be able to handle multiple file uploads per question.

Here is the entire flow

Here is the entire flow.
This is the entire flow

Get the Forms response

The get the form response

Initialize an array variable to store the responses to the file upload questions

We need to initialize an array variable. The array variable will store the responses to the file upload questions. We will later loop through each question saved in the array and get every file that was uploaded. The user may upload zero, one or multiple files per question.

We need to initialize an array variable. The array variable will store the responses to the file upload questions.
We need to initialize an array variable. The array variable will store the responses to the MS Form file uploads for breakfast, lunch, teatime and dinner.

Populate the array with the forms upload dynamic content as shown in the examples below:

Populate the array with the forms upload questions
Populate the array with the MS Forms dynamic content.

Please pay close attention to the format of the array variable:

Pay close attention to the format of the array variable
Pay close attention to the format of the array variable!

Initialize another array variable to store the attachment filenames and content

This array variable will be used to append (store) the attachment filenames and content):

Initialize another array variable to store the attachment filenames and content
Initialize another array variable to store the attachment filenames and content

The array will be attached to the Approval action later in the flow.

The Apply to each loop for questions

We need to loop through each question (now stored in varFileUploadQuestions) using an Apply to each loop:

As we loop through each question using an Apply to each loop we need to get every file that was uploaded and for that we will need to use a second Apply to each loop. Remembet that a user could upload multiple files.

Check if a file was uploaded

Let’s add a condition action to the flow to check whether the user uploaded a file:

Check if the user uploaded a file for the quesiton

Our Apply to each loop now looks like this:

If a file was uploaded we can continue with the approval workflow in the Yes block. But if no file was uploaded, we take no further action and the No block is left empty. For a deeper dive into how this condition check works, see How to send Microsoft Forms file uploads to an Approval workflow using Power Automate.

The Apply to each loop 2 in the Yes block

We need to loop through the details about each file that was uploaded and for that we will use another Apply to each loop:

We need to loop through the information about each file that was uploaded using another Apply to each loop.
For each forms file upload control we need to loop through the information about each file that was uploaded – and for that we need another Apply to each loop!

We need to get the following information about each file:

  • filename
  • file content

and then append the filename and file content to the attachments array.

We need the filename and content of the uploaded file. We then append this information to the attachments array.
We need the filename and content of the uploaded file. We then append this information to the attachments array.

This is the overall view of the Apply to each loop. I will break this down into their individual actions below.

The overall view of the Apply to each loop 2
The Apply to each loop 2. Click on the image above for a larger view of this part of the flow.

The Apply to each loop requires information about the uploaded files to be in JSON format. We can construct an expression to get this information into JSON format by “wrapping” the dynamic content for the question’s file upload property inside a json function:

"Wrap" the dynamic content for the file upload property inside a JSON function.
“Wrap” the dynamic content for the question’s file upload property inside a JSON function using an expression. Click on the image above for a larger view of this part of the flow.

Get file metadata Action

Add a Get file metadata action:

The Get file metadata action. Click on the image above for a larger view of this part of the flow.

and use the following expression as the file value:

items('Apply_to_each_2')?['id']

This action will later helps us easily get the name of the uploaded file and its content.

Get file content action

Next we get the file content using the Get file content action as shown below:

Close up of the get file content action
The Get file content action. Click on the image above for a larger view of this part of the flow.

Fill the array with the filename and file content

Add (append) the filename (Display name) and file content to the attachments array:

Click on the image above for a larger view of this part of the flow.

Here is closer view of the append to array action. The content of the array requires a specific format if it is going to be used as an attachment in the approval action:

Here is closer view of the append to array action. The content requires the following  specific format if it is going to be used as an attachment in an approval action.
The content of the array requires a specific format if it is going to be used as an attachment in an approval action

You can type the content in manually or you can copy-and-paste the following code:

{
  "name": @{outputs('Get_file_metadata')?['body/DisplayName']},
  "content": @{body('Get_file_content')}
}

We have now completed the acitons for the Yes block :

The completed the acitons for the Yes block
The completed the acitons for the Yes block

The Approval action

This is the flow so far:

This is the flow so far. The final step is the approval action.
This is the flow so far. The final step we need to add is the Approval action which is highlight in red.

The final action is to add an approval action (e.g. Start and Wait for an approval) and insert the array variable in to the approval action:

Approval actions with attachments
When adding the attachments array variable you need to switch to “input the entire array” mode.

And that’s it for this flow.


Runtime outputs

Here is an example of a form with four menu files being uploaded:

A sample form with four files upload "questions"
A sample form with four menu files upload “questions”: Four files have been uploaded for breakfast, lunch, teatime and dinner.

Example email notification

Note below that the four menu file attachments have been sent along with the email notification:

Example approval workflow email notification
Example approval workflow email notification. Note the four file attachments for breakfast, lunch, teatime and dinner.

Example Teams approval notification

Note that file attachments don’t appear in Teams approvals:

Note that the file attachments don't appear in Teams approvals
Teams approval notifications. Note that the file attachments don’t appear in Teams approvals! ☹️

This may be a bug or a limitation of the current approvals notification sent by Power Automate. Have you found a way to make the attachments appear in the Teams app?


Attachments not appearing in the approval notification message?

I have found that forms file attachments only appear in the email approval notification sent by Power Automate. File attachments don’t appear in the Teams approval so make sure that you have enabled notifications for the approval action. By enabling this setting Power Automate will send an email notification messages to the approver:

Make sure you enable notifications for the approval action
Make sure you enable notifications for the approval action

Corrupt attachments? Attachments won’t open?

Attachments won't open

Different solutions on how to construct the attachments array have been discussed in Power Automate forums. The flow I have presented here seems to work with Forms file attachments for approval workflows.

However, if you find that in some instances the above does not work, i.e., the file attachment won’t open, I have included an alternative format for the attachments array.

You can copy and paste the following code in to the Append to Approval Attachments array variable action as shown above:

{
  "name": @{outputs('Get_file_metadata')?['body/DisplayName']},
  "content": {
    "$content-type": @{body('Get_file_content')?['$content-type']},
    "$content": @{body('Get_file_content')?['$content']}
  }
}

For further information about this, see:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: