Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

Approve a File Uploaded via Microsoft Forms

Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional

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

*This post is locked for comments

  • Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional
    Posted at
    Approve a File Uploaded via Microsoft Forms

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

  • Community Power Platform Member Profile Picture Community Power Pla...
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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? 

  • Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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.

     

     

  • Community Power Platform Member Profile Picture Community Power Pla...
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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? 

  • Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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.

  • rolandgiger Profile Picture rolandgiger
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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

  • Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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.

  • rolandgiger Profile Picture rolandgiger
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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

  • Pstork1 Profile Picture Pstork1 66,174 Most Valuable Professional
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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.

  • benidoink Profile Picture benidoink 73
    Posted at
    Approve a File Uploaded via Microsoft Forms

    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"
            ]
        }
    }