Add attachments from Forms to Microsoft Lists using Power Automate (UPDATED)

Note: The “Get file content using path” and “Apply to each – Add attachment” actions have updated from my original post to correct an issue where the content from multiple attachments was being duplicated.


In my previous blog post I outlined how Power Automate can be used to get responses from Microsoft Forms into Microsoft Lists. As a follow up to that post, I will show how to add attachments from Forms to Lists using Power Automate. See my previous blog post for the form, list and Flow build.

From Power Automate, click “New step”, search for “Data Operation” and select the “Compose” action. This action will generate the required JSON schema needed to parse the attachment JSON.

  • Set “Inputs” to “Associated files” from the Forms “Get response details” action.
Compose action

Test the Flow and when complete expand the “Compose” step and copy the Outputs.

Compose action output

Click “New step”, search for “Data Operation” and select the “Parse JSON” action. This action will extract the attachment metadata.

  • Set “Content” to “Associated files” from the Forms “Get response details” action.
  • Click “Generate from sample” and paste the “Compose” outputs into “Schema”.
Parse JSON

Click “New step”, search for “Data Operation” and select the “Compose” action. Power Automate will automatically add a “Apply to each” loop.

  • Set “Inputs” to “name” from the “Parse JSON” action.
Compose to extract names

Click “New step”, search for “Control” and select the “Apply to each” action. This action will allow us to loop through all of the form response attachments and attach them to our list item.

  • Set “Inputs” to “Body” from the “Parse JSON” action.

Click “New step”, search for “OneDrive for Business” and select the “Get file content using path” action. This action will extract the attachment content.

  • Set “File Path” to your Forms attachment location, i.e. “/Apps/Microsoft Forms/Issue tracker/Question/” and add “name” from the “Parse JSON” action.
OneDrive for Business - Get file content using path action

Note: Forms stores attachments in your OneDrive under “/Apps/Microsoft Forms/form name i.e. “Issue tracker”/Question/”.

Click “New step”, search for “SharePoint” and select the “Add attachment” action.  

  • Set the “Site Address” and “List Name” to you target site and list.
  • Set “Id” to “ID” from the previous “Create item” action.
  • Set “File Name” to “name” from the “Parse JSON” action.
  • Set “File Content” to “File content” from “Get file content using path” action.
SharePoint Add attachment action.  

My completed Flow looks like the image below.

My completed Flow

Save your Flow and test by submitting a new item from the “Issue tracker” form. If all goes well your Forms submission will be stored in Microsoft Lists and the attachments will be added to the List entry.

List entry with attachments.

Forms is another excellent tool for citizen developers in the Microsoft 365 toolbox. Getting Forms response data and attachments into Microsoft Lists provides so many opportunities for business process automation using Power Automate without relying on “traditional” IT.

Thanks for reading.

NY

18 thoughts on “Add attachments from Forms to Microsoft Lists using Power Automate (UPDATED)

  1. Hi Norm, thanks for the walkthrough but just have one issue. It seems to work with all file types except for PDFs. The flow completes successfully and i see the attachment uploaded but when i try to look at the attachment, it says ‘Failed to load PDF document.’

    Like

    1. Hi Isac,

      This is not what I would have expected. Is the attachment a standard PDF or one with special bookmarks that require the Adobe PDF client to open? Does the attachment open with the OneDrive/SharePoint file viewer?

      Thanks for reading!

      NY

      Like

      1. Hi Norm,

        I figured why this is happening. I’ve set my MS Forms to allow the user to upload multiple attachments. It seems like the PARSE JSON and compose action are able to recognise and output the two attachments but i believe the formula inputted in the action ‘get file content using path’ (e.g. /Apps/Microsoft Forms/Issue tracker/Question/first(body(‘Parse_JSON’))?[‘name’]) only extracts the first attachment.

        Please correct me if i am wrong but if not, would you be able to suggest how to accommodate for multiple attachments?

        Thanks!
        Isac

        Like

  2. Hi Isac,

    Let me dig into this further. Adding multiple attachments should be possible.

    I’ll be in touch.

    NY

    Like

  3. Hi,
    I’m using the same logic to add attachment but I’m facing an issue with multiple attachment.
    In fact, the list displays multiple documents but the “get file content using path” step is reading the first name (first(body(‘Parse_JSON’))?[‘name’])
    That’s why it doesn’t worj for me.
    Any suggestion would be veray appreciated 😉

    Thanks

    Like

  4. Hello,
    very interesting post
    i’m using this logic in & current flow but I’m facing issues to have it working with several attachments

    in fact, I can see both attachments in my sharepoint item but the “Get file content using path” is not working.
    I guess it’s normal because we use the expression first(body(‘Parse_JSON’))?[‘name’]
    So it’s loading only the first name of the body

    I didn’t find a way to loop correctly.

    Any suggestion would be highly appreciated 🙂

    thxs

    Like

    1. Hi Thomas,

      The Flow does work with multiple attachments. WordPress will sometimes convert single quotes ‘ to ’. Update: first(body(‘Parse_JSON’))?[‘name’] to first(body(‘Parse_JSON’))?[‘’name’].

      Thanks for reading!

      NY

      Like

  5. Thanks for your reply. It doesn’t work for me. And I can’t apply your recommendation because it tells me the expression is invalid.

    Here is the step above where I Parse the JSON .
    The issue is that the file path use twice the same name :\Apps\Microsoft Forms\Demande d’analyse – Saint Fons (Copie)\Données Sécurité Veuillez déposer la FDS du produ\FDS_Thomas LORGE 2.pdf

    instead of \Apps\Microsoft Forms\Demande d’analyse – Saint Fons (Copie)\Données Sécurité Veuillez déposer la FDS du produ\receipt train to airport_Thomas LORGE.pdf

    [
    {
    “name”: “FDS_Thomas LORGE 2.pdf”,
    “link”: “https://elkem-my.sharepoint.com/personal/thomas_lorge_elkem_com/Documents/Apps/Microsoft%20Forms/Demande%20d%27analyse%20-%20Saint%20Fons%20(Copie)/Donn%C3%A9es%20S%C3%A9curit%C3%A9%20%20Veuillez%20d%C3%A9poser%20la%20FDS%20du%20produ/FDS_Thomas%20LORGE%202.pdf”,
    “id”: “01NVQRYGWYS2JFMTOAPRA3X7NOKBZLKYAF”,
    “type”: null,
    “size”: 1818360,
    “referenceId”: “01NVQRYGSWLO2ZLARLYBBYFTTKOGLGMC2N”,
    “driveId”: “b!da_GQCGNTU-TpCq0a75y0fKw_skVS0xBqz7NHiYKvrzmRuCsFE47Q7RDO2bruoQi”,
    “status”: 1,
    “uploadSessionUrl”: null
    },
    {
    “name”: “receipt train to airport_Thomas LORGE.pdf”,
    “link”: “https://elkem-my.sharepoint.com/personal/thomas_lorge_elkem_com/Documents/Apps/Microsoft%20Forms/Demande%20d%27analyse%20-%20Saint%20Fons%20(Copie)/Donn%C3%A9es%20S%C3%A9curit%C3%A9%20%20Veuillez%20d%C3%A9poser%20la%20FDS%20du%20produ/receipt%20train%20to%20airport_Thomas%20LORGE.pdf”,
    “id”: “01NVQRYGSMMLU2M2PW6ZCZFZJW2QQGJMEJ”,
    “type”: null,
    “size”: 47156,
    “referenceId”: “01NVQRYGSWLO2ZLARLYBBYFTTKOGLGMC2N”,
    “driveId”: “b!da_GQCGNTU-TpCq0a75y0fKw_skVS0xBqz7NHiYKvrzmRuCsFE47Q7RDO2bruoQi”,
    “status”: 1,
    “uploadSessionUrl”: null
    }
    ]

    Like

    1. Hi Thomas,

      I’ll happy to help but need more info. Expression code, error message and screen prints of each.

      NY

      Like

      1. Hi,
        I’m sorry I’m a bit new on this blog, but i can’t paste screen copies, or attach files.
        do you want me to send you details by email or is there a way to proceed via the blog ?
        thxs

        Like

  6. Hello Norm, I want add an attachment from “for a selected item” user input as an attachment to a list item in sharepoint. I suspect the concept is close to what you have demonstrated above but I am a bit stuck. Do you an example?

    Like

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 )

Google photo

You are commenting using your Google 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