cancel
Showing results for 
Search instead for 
Did you mean: 
Pstork1

Approve a File Uploaded via Microsoft Forms

Step #1 – Upload the file using Microsoft Forms

The first step is to create a Microsoft Form that can be used to upload a file.  There are two possibilities here.  First, if you are creating the Form personally then the file will be stored in your OneDrive. But if you are creating the Form as part of an Office 365 Group then the file will be stored in the SharePoint site that was created when the group was created. Either way the file is placed in a subdirectory called ‘/Apps/Microsoft Forms/{Name of the Form}/Question/’.  This makes it easy to find the file if you are uploading files from multiple forms. The file will also be uniquely named by adding the name of the submitter to the end of the original file name.

For our purposes I created a simple MS Form that had two questions.  The first lets the responder upload a file.  MS Forms has a specific question type that adds an attachment control to the form. Setting optional properties on the attachment control can also be used to limit the file extensions that can be uploaded, the maximum file size, and the maximum number of files. The second question is a text question used for the user to submit the email address of the person who is going to approve the file. Here’s a screenshot of the form I created.

image.png

Step #2 – Create an Approval flow

Now that we’ve used MS Forms to submit the file lets create a Power Automate flow to approve the file. Here’s a screenshot of the completed flow.  We’ll come back and examine each action.

image.png

The flow is triggered when a new response is submitted to MS Forms. Unfortunately, the trigger doesn’t contain dynamic content that includes all the responses.  So we have to follow the trigger with a Get Response Details action to get the responder’s email address, the approver’s email address and the name of the file that was uploaded.  Here are the details for the MS Forms trigger and actions we are using. For the trigger the only parameter you need is to pick the form that you used to upload the file. Then get the details by picking the form and supplying the ID of the response returned by the trigger.

image.png

Once you’ve gotten the details from the form you need to isolate the Id of the file that was uploaded so you can share it with the Approver. The easiest way to do that is to Parse the JSON response from the Form response details. The trick here is to run the flow once before adding the Parse JSON action so you can get a sample output to use to generate the schema. Here’s a screenshot of the Parse JSON action.

image.png

Now that we have access to the Id for the file we can use that to create a sharing link to use in our approval so the approver can access the file.  However, even though we limited the Form upload to only one file it will return the file information as a collection.  So we’ll use a First() function to get the one record out of the collection to use with the Create a Share Link action. The formula to feed into the File parameter is ‘first(body('Parse_JSON'))?['id']’. We set the action to provide a Link that is available to an anonymous user and provides only View permission.

image.png

Now that we have the link we can create the Approval.  We fill out the Approval action as shown in the screenshot below with the email of the Approver from the Form response and the sharing link we generated above.

image.png

Once the Approver responds to the Approval we can complete the flow by sending an email back to the person who filled out the original Form with whatever details we want to supply.   The Send an Email V2 action uses the Responder’s email from the original Form Details action at the start of the flow.

image.png

That completes this walkthrough.  This should provide enough detail to get you started if you want to approve a file uploaded via an MS Form.

Comments

Hello @Pstork1 

 

Question....how do I include multiple files.

 

My form has

-question #2 for the expense report file (I can do this successfully with the above information)

-question #3 for the credit card statement

-question #4 for the receipts

Approvals really aren't designed to do multiple files in a single approval.  You could pull together a list of links in a string variable and then use that in the Approval Body.  

Hi @Pstork1 - thank you for doing this - really helped with my work today.

 

I just have one question, when someone else fills out the form, it shows my name as the requestor and not the responder? Is there any way around this?

 

And with creating the share link, the file is stored in my personal OneDrive folder - can that be changed to a more central location?

 

Much appreciated 🙂 

If you add a question to the form where the person adds their email you can change the requestor in the advanced options in the Start and Wait for approval action.

 

For the share link you can create the file in SharePoint and share it from there.

Hi @Pstork1 ,

 

Please confirm if my idea will work.

I will create an Approver List save in Sharepoint List. 

The condition is " If the requester name (MS Forms Field) is equal to Approver Name (Sharepoint List Approver)." Once it's succesful, The file uploaded from Forms will automatic save on the sharepoint.

 

Thanks

Yes, that should be possible.  The one thing I would suggest is to use the Requestor's email instead of their name.  Names aren't guaranteed to be unique.

Anonymous

I am having trouble generating the Parse JSON schema. and the flow can't run without a schema. Is there a code to copy+paste for Schema, or is there another way around this?

 

Hi @Anonymous ,

Try to use this Schema.

{
    "type""array",
    "items": {
        "type""object",
        "properties": {
            "name": {
                "type""string"
            },
            "link": {
                "type""string"
            },
            "id": {
                "type""string"
            },
            "type": {},
            "size": {
                "type""integer"
            },
            "referenceId": {
                "type""string"
            },
            "driveId": {
                "type""string"
            },
            "status": {
                "type""integer"
            },
            "uploadSessionUrl": {}
        },
        "required": [
            "name",
            "link",
            "id",
            "type",
            "size",
            "referenceId",
            "driveId",
            "status",
            "uploadSessionUrl"
        ]
    }
}

For the Parse JSON schema

1) Run it once using {} empty braces as the schema

2) Take the output of that run and use it to generate the schema

 

Check Step #3 in the Blog.  The schema will be dependent on your specific Form, so there is no one schema that will work in every case.

Thanks for that helpful blog post @Pstork1 !
One question: In the flow picture at the beginning, one can see the step "find files in folder", but it's not mentioned in the text. Is that needed?

What would need to be filled for "Search Query"?

Thanks,
Roland

No, that step isn't necessary.  I used it during testing to look at the files that were uploaded. But forgot to remove it from the screenshot.

Thanks a lot @Pstork1 for that quick response!

 

That's good to know. Then I need to continue my search for the error messages I get.

When I use my personal OneDrive, I get "The operation failed because sharing has been disabled on this site."

 

And when I use an MS Teams SharePoint site from a Office 365 Group, I get "The provided item ID is not valid for the requested drive".

 

I probably can fix the one with my personal OneDrive with the IT support of my company to enable sharing for my OneDrive

Otherwise, that flow would be awesome! 🙂

Thanks,

Roland

When you say OneDrive do you mean OneDrive for Business?  If you do then you need to talk to your Office 365 admins.  They have disabled your ability to create a sharing link from OneDrive for Business.  The flow uses OneDrive for Business because that is where MS Forms will save the file.  If you want to use SharePoint you need to get the file content and create a new file in the SharePoint location and use that.  Or you could get the content and add it as an actual attachment to the Approval instead of including a sharing link.  Both would require additional actions.

Anonymous

I don't know json at all so the directions to run a flow and then use the output to create the schema does not help me at all. Any chance you could walk me through what that means step by step? 

1) Use {} for the schema in the Parse JSON when you first start.

2) Run the flow once

3) Copy the output from the run, then edit the flow, select the "Generate from Sample" button on the bottom of the parse JSON and paste what you copied into it.

 

 

Anonymous

Thank you! That seemed to work, though I am getting the following error: 

 

The 'inputs.parameters' of workflow operation 'Create_sharing_link_for_a_file_or_folder' of type 'OpenApiConnection' is not valid. Error details: Input parameter 'id' is required to be of type 'Integer/int64'. The runtime value '"01JL6ZAQMHVI7AFH6OGJFZKSXDL6YLNN7P"' to be converted doesn't have the expected format 'Integer/int64'.

 

Any ideas? 

Check which ID you are using.  You're using the GUID not the INT ID for the file item.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/