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 do I delete an ima...
Power Apps
Unanswered

How do I delete an image attachment from a Sharepoint list item in my Power App?

(0) ShareShare
ReportReport
Posted on by 42

I have a power app in which the user can attach images to a Sharepoint list. My app is modeled after this Reza Dorrani youtube video. I have an app screen that contains a vertical photo gallery in which I want the user to be able to delete an image attachment by clicking on the trash icon on the right hand side of the gallery. However, I'm not sure what the OnSelect code should be for that trash icon. At first I had this as the code:

 

 

RemoveIf(colImages,DisplayName= ThisItem.DisplayName);

 

 

because that is what Reza used as his code at 12:18 of his video. I realized that that code was wrong, probably because I should be deleting something from my sharepoint list called "BeckTable" rather than from the camera collection "colImages". Therefore I changed my code to this, but I received an Invalid Arguments error:

 

 

Remove([@BeckTable],ThisItem.Value);

 

 

Does anyone know what code I should use for that trash icon in order for the user to successfully delete a particular image attachment from a list?

 

GalleryScreen.JPG

Categories:
I have the same question (0)
  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @powaya ,

     

    I would suggest if you are ready to use a flow for this purpose. The flow issue solution is mentioned in below link. 

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Delete-a-specific-attachment-in-a-sharepoint-list/td-p/489787

     

    Let me know if any other approach you want to delete the attachment.

     

       

  • powaya Profile Picture
    42 on at

    @PriyankaGeethik  I created a flow as you suggested (screenshot below) and then I inserted the following code into the OnSelect of the trash icon. I got the following syntax error:  "Invalid number of arguments. receive 2:  expected 1". Do you know what my OnSelect code should be so that the flow will successfully delete this image attachment?

     

    PowerAppsbutton.Run(
     BrowseGallery1.Selected.ID,
     LookUp(
     BrowseGallery1.Selected.Attachments,
     DisplayName = ThisItem.DisplayName
     ).Id
    )

     BeckTableFlow.JPG

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @powaya ,

     

    It seems you used same Deletedattachment variable in the Flow for id and File identifier thats why the flow is actually wanting only 1 variable instead for 2 

  • powaya Profile Picture
    42 on at

    @PriyankaGeethik Ah ok I thought the solution/link that you gave used the same Deletedattachment variable in the Flow for id and File identifier. Could you let me know exactly what I should put in the id and File identifier fields, and if my OnSelect code looks correct?

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @powaya ,

     

    Sorry for the delay. 

    Yes in your power automate use Ask in PowerApps for second element like you added for the first. Your on select seems fine. 

     

     

  • powaya Profile Picture
    42 on at

    Hi @PriyankaGeethik , I think I'm getting closer thanks to your help. Here is my OnSelect code (which I simplified to only 1 parameter) and flow screenshot. At the moment the attachments are not deleting when I click the trash icon in my Photo Gallery. I click on the trash icon and nothing happens. Can you help me figure out why that is? I can send you any screenshots that you need.

     

    PowerAppsbutton.Run(
     BrowseGallery1.Selected.ID
    )

     

    BeckTableFlow2.JPG

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @powaya ,

     

    Indeed you are getting closer. Only what I meant by Ask in PowerApps is mentioned below. When you open the flow on the marked side you will see [See More] click on that and than you will be able to see Ask in PowerApps variable. 

     

    Please revert back the onselect because after changing the Flow you will be able to send 2 variables in your run command. 

     

    PG_WorXz10_0-1633499158413.png

     

     

     

  • powaya Profile Picture
    42 on at

    @PriyankaGeethik Thanks for your reply. I selected the purple "Ask in PowerApps" item and it defaults to the "Deleteattachment_Id" that you see in the image below. If I hover over that purple item, it says triggerbody()['Deleteattachment_FileIdentifier']

     

    Also, I changed my OnSelect code to the following below, with 2 parameters. Now, the problem is that this flow is deleting the entire list item in sharepoint rather than the particular image attachment that I'm trying to delete. How can I change my code or my flow so that it targets the specific attachment rather than the entire list item?

     

     

    DeletePicture.Run(BrowseGallery1.Selected.ID,BrowseGallery1.Selected.Identifier)

     

     

    BeckTableFlow3.JPG

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
Haque Profile Picture

Haque 94

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard