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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / same file name exists ...
Power Apps
Answered

same file name exists in the attachment control

(1) ShareShare
ReportReport
Posted on by 314
Hi,
How to check if same file name are attached into attachment control at same time?
Thanks!
Categories:
I have the same question (0)
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    hey
     
    what you can try is the following:
    If(
        CountRows(
            Filter(
                GroupBy(AttachmentControl.Attachments, "DisplayName", "GroupedFiles"),
                CountRows(GroupedFiles) > 1
            )
        ) > 0,
        Notify("Duplicate file names are not allowed.", NotificationType.Error),
        // Proceed with your normal logic, like submitting the form or saving the data
        SubmitForm(EditForm)
    )
    
    this can be put in the onselect of a button for example. you need to rename to your needs
     
    let me know if it works, if it did  please mark as verified answer
  • usaman45 Profile Picture
    314 on at
    I appreciate your assistance, but I encountered difficulties using the GroupBy function. I am uncertain about the cause; do you have any insights?
  • Verified answer
    WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    The code from mmbr1606 is correct, except you do not need quotes "" around the GroupBy parameters and DisplayName needs to be Name. An alternative is below (to be used OnAddFile of the attachment control), but the main reason for my post was that also you need to know that you cannot have two files of the same name in an attachment control - the second one will replace the first one when saved.
    If(
       CountRows(
          Filter(
             Self.Attachments,
             Name = Last(Self.Attachments).Name
          )
       ) > 1,
       Notify(
          "File already stored",
          NotificationType.Error,
          4000
       );
       Reset(Self)
    )
     
    Please click 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 giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard