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 / How to prevent attachm...
Power Apps
Suggested Answer

How to prevent attachment file duplicates

(0) ShareShare
ReportReport
Posted on by

Hi all,

 

I’m trying to prevent users from submitting duplicate files in the attachment section.

I added the following logic in the OnAddFile property. It successfully detects duplicate files, but it does not remove the duplicate from the attachment control.

I would prefer not to use Reset(Self), since that would remove all files. Instead, I’d like to:

- remove only the duplicate file, or

- ensure that if the same file is uploaded multiple times, it only appears once in the attachments list.


     
With(
{ newName: Lower(Last(Self.Attachments).Name) },
    If(
        CountIf(Self.Attachments As f, Lower(f.Name) = newName) > 1,
        Notify("This file has already been uploaded.")
    )
)
iShot2026-03-20 14.25.45.png
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    154,621 Most Valuable Professional on at
    This should work for you - put this OnAddFile of the Attachment Control
    If(
       CountIf(
          colAttach, 
          Lower(Name) = Lower(Last(Self.Attachments).Name)
       ) > 0,
       Notify(
          "This file has already been uploaded",
          NotificationType.Error,
          5000
       );
       Reset(Self),
       Collect(
          colAttach, 
          Last(Self.Attachments)
       )
    )
    and set the Items of the Attachment control to 
    colAttach
     
    The problem is that you cannot programatically delete an item from an attachment control, so you nned to use a collection for the Items and manage that. Resetting the control in this instance will "delete" the new item and revert it back to the existing collection without it added.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 562 Most Valuable Professional

#2
11manish Profile Picture

11manish 324

#3
Haque Profile Picture

Haque 303

Last 30 days Overall leaderboard