cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChadVKealey
Memorable Member
Memorable Member

Working with files from the Forms "File Upload" question type

I was very excited to learn that the "File Upload" question was coming to MS Forms. We have a LOT of scenarios where we want to collect files from people in a way that also collects some metadata, so this will be very useful. However, I'm having a bit of trouble accessing those files from Power Automate.

 

So, I have a form that will be used to collect Syllabus files from faculty. They'll need to enter some course info which will be used as metadata on the uploaded file. The form automatically puts the file into a folder named after the form, several layers down in the Documents library (which I'm not thrilled about, but whatever). What I want to do is move that file to a separate document library with columns to accept the metadata. 

 

The Get Form Response action returns the file upload question response in a block that, I guess, needs to be parsed out? This is what it provides:

"r9e51ca9ff4b8420e9dd54ab305d36805": "[{\"name\":\"<file_name>.pdf\",\"link\":\"https://<tenant>.sharepoint.com/sites/<site_name>/Shared%20Documents/Apps/Microsoft%20Forms/<form_name>/Question/<file_name>.pdf\",\"id\":\"01H7BFDJ7AEHYC2NLCRJGK5UT5FNKG2ID4\",\"type\":null,\"size\":41382,\"referenceId\":\"01H7BFDJZUQGHQ4UHE6ZHLCOFMB5D24YRC\",\"driveId\":\"b!4cQiASLhPUq8SGSD21oPlB3OwJfDzrJMtPR2NlkFKObx4in0iZlARpy7sxn656jT\",\"status\":1,\"uploadSessionUrl\":null}]"
 
What I need is a way to reference the elements within that. Specifically, the "link", which I can then feed into the appropriate SharePoint actions to get that file and move it to/create it in the appropriate library. 
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ChadVKealey,

 

After you get the JSON, please add parse JSON action, then you will get two dynamic content you can using in the following steps - dirveId and id.

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

Then you can get the file content by using the Get file content action of OneDrive for Business connector, append the driveId and id into the File ID field, please notice that the dot between them:

Annotation 2019-12-18 180014.png

After all, you can create file by the file content.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
manuelstgomes
Community Champion
Community Champion

Hi @ChadVKealey 

 

Can't you use the file that is returned from the form to upload to SharePoint?

2019-12-16 15_31_30-Create your flow _ Microsoft Power Automate.png

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

@manuelstgomes , unfortunately, that won't work. I need to figure out (or have someone show me) how to parse out what's returned as the "uploaded file data". It's not JSON, exactly...I'm not sure what it is. But, I'm sure there's a way to pull it apart to get the Path and Display Name values, which are what I need.

Hi @ChadVKealey,

 

You could find these files in the details of the responses:

Annotation 2019-12-17 154308.png

 If you want to get its properties apart from the answer, you can use the expression json():

Annotation 2019-12-17 154716.png

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-litu-msft , could you share the expression in the input of the second Compose action? 

Actually, using the Parse json action, I can get the elements/details of the file, but it looks like "path" and "file identifier" are not among them, at least not in the forms needed by "Get file metadata from path" or "Get file metadata". The "Link" is there, so I suppose it would be possible to extract the path from that, I'm just not very good at writing those kinds of expressions. 

Hi @ChadVKealey,

 

After you get the JSON, please add parse JSON action, then you will get two dynamic content you can using in the following steps - dirveId and id.

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

Then you can get the file content by using the Get file content action of OneDrive for Business connector, append the driveId and id into the File ID field, please notice that the dot between them:

Annotation 2019-12-18 180014.png

After all, you can create file by the file content.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-litu-msft ! I'm actually using a Group Form, so the files are going into a SharePoint Document Library, not my OneDrive. I tried using the "Get file metadata" and "Get file content" actions from the SharePoint connector with the driveid.id as the "identifier" and it would fail to locate the file. However, using the actions of the same names from the OneDrive for Business connector, it's able to get the file and its contents. Considering the file is stored in SharePoint, not OneDrive for Business, I'm surprised that the OD4B actions worked. 

 

This is a potentially huge time-saver for a lot of our departments!

Anonymous
Not applicable

@ChadVKealey Sorry I've i've misinterpreted - did you manage to get it working with group forms? 

 

Struggling with the same issue so any help appreciated!

@Anonymous , yes, I did get it to work, using the OneDrive for Business actions in Power Automate to get the files from the Documents library in the Group's SharePoint site. See this video for the end-to-end walkthrough of a process I built for academic departments to collect syllabi from faculty: https://youtu.be/fjdhb9_m7Ho (or, jump to https://youtu.be/fjdhb9_m7Ho?t=440 to view just the part about Power Automate). 

 

I think this could be done using the "get file..." actions in the SharePoint connector, but finding the right combination of action, properties and values could take some trial and error. Considering OneDrive (for Business, anyway) is based on SharePoint, it's kind of frustrating that there are different actions and capabilities from the Power Automate perspective. Some other connectors treat them as equivalents. For example, some of the "Excel (Business)" actions have inputs for the file location and the drop-down shows "OneDrive for Business" and then all of the SharePoint sites/libraries to which the user has access. 

Anonymous
Not applicable

@ChadVKealey  thanks for the response & the link. I will try again with the Onedrive for business connection instead as I've spent too long in the trial and error stage of the sharepoint equivalent! Despite all the hope that this post gave me!

Cheers

ThomasH
Helper II
Helper II

Hello, i have the Problem, that i woult become Files from the Forms Upload to my Planner, and i think, this here can be my solution, but i don't understand what i have here to do

ThomasH_0-1655698249981.png

What Code must in the "outputs(...)  ?

 

ThomasH_1-1655698404688.png

 

Thank you

 

 

This video should help: https://youtu.be/wg5xzN2TEok

 

The difference with planner "attachments" is that the files are not actually attached to the tasks in the same way that files would be attached to an email or SharePoint list item. The task stores links to the files. If it's a group form, they would be stored in the SharePoint site of the group. If the plan is connected to the same group, you can just add the links. If it's a personal form, or the form and plan are NOT connected to the same group, then you need to either create an appropriate sharing link to the file, or copy it to the site connected to the plan.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,827)