How to Send Microsoft Forms File Uploads to an Approval Workflow Using Power Automate

This post was last updated:

This beginner’s tutorial will guide you through the process of creating an approval workflow for file attachments submitted via a Microsoft Form.

The flow will attach the uploaded file attachments to the approval action, making it easy for approvers to review and act upon them. This workflow is designed to work seamlessly even when multiple files are uploaded. By the end of this tutorial, you will have a solid understanding of how to create an approval workflow that utilises file attachments from a Microsoft Form.

The steps in the flow

  1. A user completes a Microsoft Form and uploads files
  2. Get the user’s Forms response
  3. For each file that was uploaded, get its filename and content (uploaded files are stored in OneDrive)
  4. Create an Approval and add attachments to the approval action

This is the Form we will use for the demo

Example Microsoft Form. The form contains a file upload control.
Example Application form created with Microsoft Forms showing the file upload control in Question 6.

What to do if your form has more than one File Upload question

The flow assumes that the Application form has only one file upload control. However, your form could have multiple file upload controls as we see in the example form called Weekly Menu Upload.

The flow assumes that the Application form has only one file upload control.  However, your form could have multiple file upload controls as we see in the example form called Weekly Menu Upload.
The Application Form on the left only has one File Upload question while the Weekly Menu Upload form has four File Upload questions

If your form has multiple file upload controls then see How to send Microsoft Forms file uploads with multiple questions to an Approval workflow using Power Automate.

The flow also assumes that file uploads are a required field meaning that users are required to attach a file before submitting the Application form:

The flow assumes that file uploads are a requied field meaning that users need to attach a file before submittig the form
The flow assumes that file uploads are a required field

If file uploads are optional in your form, then continue to follow the tutorial below, then make the changes as shown in the section Form is submitted without an uploaded file and the flow fails .

Here is the entire flow

Here is the entire flow.

Get the Forms response and initialize an array variable

We get the form response and initialize an array variable. The array variable will be used to store the attachment filenames and content:

The get the form response and initialize an array variable.

The Apply to each loop

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

We then 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.

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
The Apply to each loop. 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 get this information into JSON format by “wrapping” the dynamic content for the Upload your file property inside a json function:

The apply to each loop requires information about the uploaded files to be in JSON format.
“Wrap” the dynamic content for the Upload your file property inside a JSON function. Click on the image above for a larger view of this part of the flow.
How to “Wrap” the dynamic content for the Upload your file property inside a JSON function.

Get file metadata Action

Add a Get file metadata action:

Close up of the 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')?['id']

This action will later help 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')}
}

The Approval action

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 the flow.


Runtime Outputs

Here is an example forms file with three files that have been uploaded:

Here is an example of a forms file upload
Forms file upload with three files attached

Example email notification

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

Example email notification.  Note that the file attachments have been sent along with the email notification.
Example approval workflow email notification

Example Teams approval notification

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

Example Teams approval notification.  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?


PROBLEM #1: 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:

So make sure you enable notifications for the approval action:

PROBLEM #2: 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:


PROBLEM #3: Form is submitted without an uploaded file and the flow fails

If a file upload is an optional requirement in your form, a user could submit a form without a file and this will cause the flow to fail as there will be no file for the flow to process:

The flow failed because no file was loaded with the form.
The flow failed because no file was loaded with the form.
Action 'Apply_to_each' failed
Action ‘Apply_to_each’ failed

To fix the error you could (1) make the file upload a required field, or (2) change the flow to handle the situation if no file was uploaded.

Option 1: Make the file upload a required field

To fix this make the file upload a required field. The flow does not need to be changed.

A simple way to fix the error is to make the file upload a required field

Option 2: Change the flow to handle no file uploads

We can determine whether a file was uploaded or not by checking the forms response. We need to look at the content of the file upload field (property) shown below as Upload your file :

We can determine whether a file (or files) was uploaded examining the forms response

The Upload your file propetry field (it’s actual internal name inside my flow is r39184e70bc0845338547b8ac381488fd) will be empty if no files were uploaded. If a file was submitted with the form it will not be empty:

The file upload field will be empty if no files were uploaded. It will not be empty if a file was submitted with the form
The file upload field will be empty if no files were uploaded.

So let’s add a condition action to the flow to check whether the Upload your file property is NOT empty (i.e. it contains a file).

Check if the file upload field contains a file.
Check if the file upload field contains a file.

If the file upload field is not empty a file was uploaded and we can continue with the approval workflow as before. But if no file was uploaded, the flow will end at this point and we will take no further action in this demo flow as the purpose of the flow is to approve the file uploads. You can add actions to the No block below for when no file was uploaded by the user, such as sending an email to the submitter asking them to submit the approval if required.

If the file upload field is not empty then we can continue with the approval workflow
If the file upload field is not empty then we can continue with the approval workflow

The updated flow should now looks like this:

Image of the updated flow. If no file was uploaded, the flow will end and no further action will be taken.
The updated flow: if no file was uploaded, the flow will end at this point

Alternative ending…

However, if you may want to still continue with the approval workflow even when a file was not uploaded. We need to make another change. Move the Start and wait for an approval action to the end of the flow. You should be able to select the Start and wait for an approval action and drag it outside of the Yes block:

Move the start and wait for an approval action to the end of the flow
Move the Start and wait for an approval action to the end of the flow
Select the Start and wait for an approval action and drag it outside of the Yes block
Select the Start and wait for an approval action and drag it outside of the Yes block

The updated flow now looks like this:

If you still want to continue with the approval workflow but without a document for approval, change the flow to the above
If you still want to continue with the approval workflow but without a document for approval, change the flow to the above


13 thoughts on “How to Send Microsoft Forms File Uploads to an Approval Workflow Using Power Automate

Add yours

  1. Thanks for sharing this. I tried to implement it, but I’m running into an issue where if a Form is submitted without an uploaded file, the flow fails. Do you know a way to make this work regardless of whether a document is uploaded or not?

    Thanks!

  2. Hi Patrick,
    Thanks for your comment. I have added a section to the end of the post that shows how to handle the situation where a file upload is an optional requirement for a form and the user submitted a form without uploading any files. Hope this helps.

    Ellis

    1. Hi Mr. E. Karim,
      Please, can you help me? I need to upload attachment from different questions on forms and send all together in the same approval .
      Thanks a lot and have a nice weekend
      Tiago A.

  3. Hi Karim,

    Thanks for writing this blog. I followed your flow exactly as you stated. I successfully received the email with the attachments in my approval email. However, I’m unable to open the documents. Need your help to rectify this issue. Thanks

    1. Hi Victor,

      Thanks for posting this question.

      I’ve updated the section “Corrupt attachments? Attachments won’t open?” in the blog post. This update offers a different format for the “append to array” action:

      {
      “name”: @{outputs(‘Get_file_metadata’)?[‘body/DisplayName’]},
      “content”: {
      “$content-type”: @{body(‘Get_file_content’)?[‘$content-type’]},
      “$content”: @{body(‘Get_file_content’)?[‘$content’]}
      }
      }

      I’ve created and tested a demo flow, and this should fix the issue.

      Recently on the Power Automate Community forums a number of users have report the same issue, the most extreme example being:
      https://powerusers.microsoft.com/t5/Building-Flows/Uploading-Excel-email-attachments-to-SharePoint-library/m-p/1768698#M195571

      The question that still needs to be answered is: Why do different array format work for some people but generate corrupt attachments for others?

      Hope this helps.

      Ellis

      1. Hi Karim,

        Thanks for the quick response. I’ll try this out and appreciate all your sharings!!

        Blessings

  4. Hi Karim,

    Fantastic blog about the Power automate

    I have a question as I am trying to create a flow for the form created for personal reimbursement. The flow must trigger a condition where a user can submit a form on the basis of the department he/she is into likes of Finance, Sales & Marketing, IT, Construction etc. the email should have the attachment and i have used the following flow in:

    when a new response is submitted > Get response details > initialize variable>Parse Json > Apply to each > start and wait for an approval

    my question is where to add a condition for flow to determine if the right department manager is selected and manager’s name then an email can send through. its an individual approval not multiple ones.

    I have looked at adding a condition before apply to each parameter, Parse Jason and even initialize variable but somehow email is not flowing after form is submitted with attached document.

    Any idea about this?

    thanks in advance if you can shed some light on this for me to finalize my pending flow

    1. Hi Yanzzah,

      I’m not entirely clear on the question. But if your form has the following choices for the departments:
      * Finance
      * Sales & marketing
      * IT
      * Construction

      …you could initialize a variable to store each departmental managers email address. We can then easily reference the departmental managers email address using a simple expression:

      Variable name: varDepartments
      Variable Type: Object
      Variable Value:
      {
      “Finance”: “finmgr@company.com”,
      “Sales & marketing”: “s&m@company.com”,
      “IT”: “itmgr@company.com”,
      “Construction”: “consmgr@company.com”
      }

      To get the departmental managers email address we can use an expression with the following format:

      variables(‘varDepartments’)?[]]

      Example:
      variables(‘varDepartments’)?[outputs(‘Get_response_details’)?[‘body/ra7a7d7d18c0644cc9076034e05daa585’]]

      The expression could be used in the Get User Profile (v2) action to return the manager’s name, job title, and location etc.

      This action(s) could be run immediately after the Get response details action.

      Best wishes,

      Ellis

  5. Excellent read. Got here via google search.
    I would like to create similar flow with two distinct changes. Form should be owned by SharePoint group (so the files aren’t saved to private onedrive, but sharpoint) and approvals sending not attachments, but sharable links to attachments.
    You ask my why? Excellent question. In my organization sharing files to external entities is forbiden, only selected few users can do that. What I would like to create is Form where any user can request file share to “outside”. I see this being done with powerautomate + forms + approve. And if approved using send email v3 action.

    1. This is a bit more fiddley.

      (1) Instead of using the Form Name as the Id in your flow actions (i.e. When a new response is submitted, Get response details), you will need to use the form id number. You can find the form id number by opening the form and then examine the URL. You need the long code after the text “id=”, for example “MeJEhiJUvUe5IE1QqXU1HjY78unqHGlAgDgzTks2TERTM1NHTUFCMlFTTiQlQCN0PWcu”.

      (2) Enter this form id value as a “custom value” in the “When a new response is submitted” and “Get response details” actions. (3) In the apply to each loop just use the “Get file content using path” action using the following expression items(‘Apply_to_each’)?[‘link’] for the file path.

      If you still get stuck, post the question on the forum and tag me in the post as @ekarim2020 . Link to the forums https://powerusers.microsoft.com/t5/Building-Flows/bd-p/BuildingFlows

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 )

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: