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 Apps / When attachment added/...
Power Apps
Answered

When attachment added/removed from item a file is created/deleted in sharepoint documents

(0) ShareShare
ReportReport
Posted on by 20

The problem I am having is when I add an attachment with a file name that already exists in the "documents" folder the flow fails. Each attachment is tied to a specific panel using a Panel ID, some panels will have the same files attached causing duplicates. Is there a way that either I can allow duplicates in the library or append a unique Id to the end of the file?

 

I am also looking for advice on deleting files from the library when the attachment is removed?

Categories:
  • Waegemma Profile Picture
    583 Super User 2024 Season 1 on at

    Hi @PowerAppsUser97 ,

     

    If I understand correctly: you use a Flow to upload a document to a library ?

     

    You could use something like:

    concat(PanelID,YourFileName)

     in the filename box, to create a unique filename.

     

    Hope this helps,

    Marc

     

     

  • PowerAppsUser97 Profile Picture
    20 on at

    Hi, Thank you for your response. I had tried this solution but it creates a new problem where the file name of the attachment (FileName) is different to the one thats is stored in documents (PanelID_FileName). Is there a simple action that renames an attachment or is deleting the attachment and reading it the only way?

  • Waegemma Profile Picture
    583 Super User 2024 Season 1 on at

    Hi @PowerAppsUser97 ,

     

    Could you explain a bit more:

     

    -the file you want to attach: is it a file in a SharePoint documents folder?

    -the attachment: is it stored in a different folder or attached to an item in a List?

     

    In Flow there is a SharePoint move action that has an option 'If another file is already there' and then you can choose 'Move with a new name' but that gives an error on my side.

     

    Marc

     

    Marc

  • PowerAppsUser97 Profile Picture
    20 on at

    Hi, 

     

    The file i want to attach is stored locally on the users machine. I want this file to attach to an item in a sharepoint list. When this is attached it then creates this file in the documents folder. 

     

    The solution above works for the creation of the file but the attachment in the list is not updated to the new name of the file. Move file is another solution that works but the naming of the file issue still exists.

     

    PowerAppsUser97_0-1660910388097.png

     

  • Verified answer
    Waegemma Profile Picture
    583 Super User 2024 Season 1 on at

    Hi @PowerAppsUser97 ,

     

    I think deleting the original attachment and attaching the new file to the item is indeed a good way,  since you have them already available in your flow.

     

    There's also this post you might already have seen: Solved: How to rename SharePoint list attachment file name... - Power Platform Community (microsoft.com)

     

    You could also reference the documents in the folder instead of attaching them, if they are not altered by the user of course.

     

    Marc

     

  • AhmedSalih Profile Picture
    6,680 Moderator on at

    @PowerAppsUser97, I usually add UTCNow() to the name of the files. 

     

     

    Regards,

    Ahmed

    If my reply helped you, please give a 👍. And if it has solved your issue, please consider a 👍 & Accepting it as the Solution to help other members of the community find it more

    My Blog: www.powerplatformplace.com

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard