web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sharepoint: Add Attach...
Power Automate
Unanswered

Sharepoint: Add Attachments to List Corrupting FIles

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

 

Im hoping that someone can help me with this issue.

Basically I have a form setup on Cognito forms that allows the user to upload some files.

When they submit it Flow pick this up and as a new record to a Sharepoint list - This is all working fine.

 

What I am tying to do is for the Attachments to also attach to that record.

 

Here what ive got so far:

 

 The Apply to Each loops through however many files there are and adds each one:

Screen Shot 2017-10-06 at 1.33.23 pm copy.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The images successfully add to the attachments:

Screen Shot 2017-10-06 at 1.34.01 pm.png

 

 

 

 

 

But when any attachment is clicked on I get this error that the file is corrupted:Screen Shot 2017-10-06 at 1.34.17 pm copy.png

 

 

 

This happens no matter what the file type is - Ive tried with PNG, PDF, XLS etc

I feel like I am so close at getting this finished haha!

Any help would be greatly appreiciated.

 

Thanks in advance!

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi AnthonyJackson,

     

    I assume that your flow might be configured likes below.


    I assume that you should have a File upload field in the form. In my case, I named the File upload field as “YourFile”. However, it seems that in the Add attachment action, I cannot get “YourFile” from the dynamic content. So I use a Compose action to get “YourFile” first then use its Output in the File content field.

    3.PNG


    The flow runs succeed. However, when I open the attachment in the list, seems that I got the same error message with you.

     

    I will help confirm with this issue on my side and back to you later.

     

    Best regards,
    Mabel Mao

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thats great thank you!

     

    Yeah Ive tried it a few different ways (that way being one of them) - All of which end the same way with the file corrupting.

    Is the attach to list a new module added recently? Or has it always been there.... I havent really noticed it until now.

     

    Thanks again

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-yamao-msft

     

    Did you manage to investigate this issue at your end?

    Many Thanks

  • SJNBham Profile Picture
    51 on at

    In order for the file content to be populated with the right data, you need to select "Content". So your flow action would look something like this:

     

    - When a new entry is created (Cognito action)

    - Create item (SharePoint action)

    - Apply to each (name of your file upload field)

    - Add attachment (SharePoint action)

    - Site Address, List Name, ID, and File Name are just how you have them in your screenshot

    - File Contet = From the Dynamic Content chooser, expand the "When a new entry is created" section and select Content.

     

    When I was trying to get this to work, I attempted the same thing as you. I emailed Cognito support to suggest they amend their KB article to illustrate this use case. Their screenshots leave these fields blank, so it's not readily apparent what should be in them: https://www.cognitoforms.com/support/63/data-integration/microsoft-flow

     

    Another thing I mentioned to their support and suggest you consider as well. If two file uploads have the same file name (e.g. image.jpg and image.jpg), then you'll want some kind of unique string added to the file name. SharePoint won't allow two files with the same name as attachments to a list item. So Cognito will email you with an integration error notice. I added the function utcNow() in front of the "Name" in the File Name field of the Add attachment action. It adds it to all of the file uploads when attachign to the list item, but at least they're all unique and won't error out. This is a very common situation where iOS devices are uploading directly from their camera instead of choosing from their photo gallery. Androids automatically create a unique file name when uploading directly from the camera.

     

     

  • SJNBham Profile Picture
    51 on at

    In order for the file content to be populated with the right data, you need to select "Content". So your flow action would look something like this:

     

    - When a new entry is created (Cognito action)

    - Create item (SharePoint action)

    - Apply to each (name of your file upload field)

    - Add attachment (SharePoint action)

    - Site Address, List Name, ID, and File Name are just how you have them in your screenshot

    - File Contet = From the Dynamic Content chooser, expand the "When a new entry is created" section and select Content.

     

    When I was trying to get this to work, I attempted the same thing as you. I emailed Cognito support to suggest they amend their KB article to illustrate this use case. Their screenshots leave these fields blank, so it's not readily apparent what should be in them: https://www.cognitoforms.com/support/63/data-integration/microsoft-flow

     

    Another thing I mentioned to their support and suggest you consider as well. If two file uploads have the same file name (e.g. image.jpg and image.jpg), then you'll want some kind of unique string added to the file name. SharePoint won't allow two files with the same name as attachments to a list item. So Cognito will email you with an integration error notice. I added the function utcNow() in front of the "Name" in the File Name field of the Add attachment action. It adds it to all of the file uploads when attachign to the list item, but at least they're all unique and won't error out. This is a very common situation where iOS devices are uploading directly from their camera instead of choosing from their photo gallery. Androids automatically create a unique file name when uploading directly from the camera.

     

     

  • GabrielStJohn Profile Picture
    Microsoft Employee on at

    Hello, @Anonymous!

     

    Thank you for posting on the Flow Community Forum! Have you had an opportunity to apply @SJNBham‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


    Thank you for being an active member of the Flow Community!

     

    -Gabriel
    Flow Community Manager

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @GabrielStJohn,

     

    I fixed this a while ago but I cant remember how - Its no longer needed now as the original post was a year ago haha!!

    So no, I havent applied any fixes posted recently 🙂

     

    Many Thanks

  • leyburn19 Profile Picture
    2,157 on at

    This also frustrated me but with the guidance above and some tweaking I got the answer.  I think the issue was mainly in the naming of the file.  So when you add an attachment you need to:

     

    1. In the file name box use something like concat(utcNow(),triggerBody()?['Signature']?['Name']) where the trigger is the update or new item created triggers for cognito.  

    2. In the File content you simply select Signature Content from the dynamic list

     

    Note as advised above I add utcNow to the name as this will make its name unique.  I have not found anthying else that will give a simpler unique ID to the attachment

    saveatt.PNG

     

  • leyburn19 Profile Picture
    2,157 on at

    Did you get the answer to this?  I do this all the time

  • siriusalsahim Profile Picture
    8 on at

    But this doesn't work for multiple attachment. I have tried and it keep failing. Please assist

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 469

#3
11manish Profile Picture

11manish 364

Last 30 days Overall leaderboard