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 / Removing Attachments F...
Power Apps
Unanswered

Removing Attachments From Button

(0) ShareShare
ReportReport
Posted on by 20

I have an attachment control in a form called addAttachments. Is there a way to remove the first item in the attachment control from a button?

 

I have a button's on select property set to Remove(addAttachments.Attachments, First(addAttachments.Attachments)) but the error I get is that the first arguments is not a collection. The addAttachments.Attachments is a table.

 

Thanks in advance!

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @mikeMar2 

    You will not be able to remove the items externally like that.  I am not entirely sure why you would have a separate button as the attachment control will already have an "X" next to the files in the attachment control that will remove the item for you.

    If you need to do something else based on an item being removed, the attachment control has an OnRemoveFile behavior that can be used to do additional steps.

     

    I hope this is helpful for you.

  • peter_not Profile Picture
    50 on at

    Hi!

    In my case, this button would be useful for testing. I want to prevent upload of files that are not .JPG.

    Once I upload an attachment that is not a .JPG (wrong file type), I would like it to be removed automatically. 

  • WarrenBelz Profile Picture
    154,494 Most Valuable Professional on at

    Hi @peter_not ,

    Try this on the OnAddFile of the attachment control

    If(
     EndsWith(
     Last(Self.Attachments).Name,
     "jpg"
     ),
     Reset(Self);
     Notify(
     "Cannot attach JPG files",
     NotificationType.Error
     )
    )

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • peter_not Profile Picture
    50 on at

    Thank you, @WarrenBelz!

    Your code resets the Attachments field, but it removes ALL the attachments, not the wrong one. 

    But I'll put some instructions about the files that are acceptable as attachments.

     

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 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard