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 / Delete an attachment i...
Power Apps
Unanswered

Delete an attachment in a CDS gallery

(0) ShareShare
ReportReport
Posted on by 137

I posted this but think I posted in the wrong section (Dataverse).

 

Anyone know what OnSelect code I use to delete an attachment from a Gallery in a Canvas App? The backend tables are in CDS.

I am trying with this code but nothing is happening: Remove(BrowseGallery1.Selected.'{Attachments}',ThisItem)

Boppersnr1_0-1661179263446.png

 

Boppersnr1_1-1661179263307.png

Here is another screenshot of how the attachments are setup in the gallery. You can see they are visible in a gallery, so I would hope its simple to write some code that when you select the Trash Icon in the gallery , it will delete the attachment. Any ideas anyone?

Boppersnr1_2-1661179301594.png

 

 

 

Categories:
I have the same question (0)
  • goel_gagandeep Profile Picture
    141 on at

    Hi @Boppersnr1 , try 

    Remove(Table_Name,Thisitem)
  • Boppersnr1 Profile Picture
    137 on at

    @goel_gagandeep Afraid I get this error:

    Boppersnr1_0-1661258827949.png

     

  • goel_gagandeep Profile Picture
    141 on at

    Put this code on OnSelect property of the trash icon which you have taken in your PhotoGallery

    Remove(Tablename,ThisItem)

    sorry for the mistake ThisItem should be in Camel case
    If it works then Please Accept it as Solution
    Thanks

  • Boppersnr1 Profile Picture
    137 on at

    @goel_gagandeep 

    I fixed the caps to ThisItem. but getting a new error:

    Boppersnr1_0-1661260771569.png

     

     

    Here how I have the gallery set:

    Items = BrowseGallery1.Selected.'{Attachments}'

    I have an image in the gallery set to this:

    Image = ThisItem.Value

    This displays all the attachments.

    Then I have an Icon in the gallery with your suggestion:

    OnSelect = Remove('Customer Site Surveys',ThisItem)

    But it is saying "Incompatible type. The collection can't contain values of this type."

     

  • goel_gagandeep Profile Picture
    141 on at

    You have to Change your Items property of the gallery use table name as an items of the gallery instead of   BrowseGallery1.Selected.'{Attachments}'

  • Boppersnr1 Profile Picture
    137 on at

    @goel_gagandeep And I suspect this is my challenge. Since I am trying to show attachments from a CDS table, I needed to use the below code on the main gallery.

    So I have a main gallery (BrowseGallery1) 

    Boppersnr1_0-1661330124067.png

    This provides a gallery of all the 'Customer Site Survey' entries based on some filter/search in this gallery. When I select an item. It brings me to a page with the attachments on display in another gallery (Gallery2).

    This is why I have the Items = BrowseGallery1.Selected.'{Attachments}'

    How would I change this to use the Table name, if the content is coming from the previous BrowseGallery1.Selected data?

  • Boppersnr1 Profile Picture
    137 on at

    @SBax Would you have any thoughts on how to do this? Would you need any more info to help diagnose my question on how to delete 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard