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

36 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

  7. Hi, tried your steps here, it works for me, the only thing im concern is just can multiple attachments compile in 1 row? Because on my end, when there is multiple attachments it creates multiple lines on the share point list.

    Like

    1. Hi Chona,

      I would review your steps and compare them with mine. My testing shows that attachments are added to a single list item.

      Let me know how you make out and thanks for reading!

      NY

      Like

  8. I have an MS form that is part of a team and my list is also part of the same team. Is there a way to just get the file path for each attachment and insert those into the List as hyperlinks instead of copying the document itself?

    Like

  9. I have an MS form that is part of a team. My list is also part of the same team. Is there a way to parse the file path of each of the uploaded documents and put the path into the list as a hyperlink instead of duplicating each of the documents?

    Like

    1. Hi docwisdom,

      It seems possible. You could use an expression to parse out the path and store the link. The Parse JSON action will have a “link” output that you can use to store the URL to the files. I would probably try a mix of the FIRST, LAST and SPLIT functions to achieve this.

      Let me know if you need help.

      Thanks for reading!

      NY

      Like

  10. Norm, I am grateful for this walkthrough. I have a question on this though. Is there an option to have the Compose/Parse JSON be conditional? The flow I have set up works perfectly when there are attachments in the MS form. The MS form I have set up allows attachments to be optional and this flow errors out when there are no attachments available.

    The error message in the Parse JSON is “Unable to process template language expressions in action ‘Parse_JSON’ inputs at line ‘0’ and column ‘0’: ‘Required property ‘content’ expects a value but got null. Path ”.’.”.

    Thank you for any feedback provided.

    Like

    1. Hi Soon,

      You can edit the JSON to allow NULL values. For example:

      “name”: {
      “type”: “string”
      },

      Can be updated to:

      “name”: {
      “type”: [“string”, “null”]
      },

      Thanks for reading!

      NY

      Like

      1. HI… i have the same issue and wish to make attachment optional. I tried your suggestion but am still getting the same error message.

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

        anything i did wrong

        Like

      2. It was the same error posted on Soon’s post. I managed to get round the problem with a conditional branch before the checking the attachment. If attachment is there, do the json if the attachment field is blank, do nothing.

        Like

      3. Hello MIndy,

        Try adding a Condition action that checks for length of the Get User ID action. If 0 then the ID does not exist.

        Hope that helps and thanks for reading!

        NY

        Like

      4. Norm, thank you for the response. I edited the JSON to allow for NULL values but am still receiving the following error: Unable to process template language expressions in action ‘Parse_JSON’ inputs at line ‘0’ and column ‘0’: ‘Required property ‘content’ expects a value but got null. Path ”.’.

        I have also edited the JSON to match what Mindy is doing below and am still receiving the same error message.

        Like

      5. Hi Soon,

        You may want to consider Mindy’s approach and add a Condition action that checks for a NULL attachments.

        Let me know how you make out.

        NY

        Like

    1. Hi Josh,

      It is complicated and I hope that you were able to implement the Flow for this use case. You are not the only one to voice your concerns on this point and I believe that Microsoft is listening. Hope this will be simplified in the future.

      Thanks for reading!

      NY

      Like

Leave a Reply to Isac Cancel 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 )

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