Announcements
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!
@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.
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.
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
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.
Congratulations to our 2026 Super Users!
Congratulations to our 2025 community superstars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 549 Most Valuable Professional
Kalathiya 225 Super User 2026 Season 1
Haque 224