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 / Remove items in galler...
Power Apps
Unanswered

Remove items in gallery function not deleting the correct items - random items are deleted instead

(0) ShareShare
ReportReport
Posted on by 14

Hi all,

 

I have created an Repeating table in a gallery connected to the collection, the items in the gallery gets patched to a collection with a button outside of the gallery. This is eventually patched to a sharepoint list.

 

The issue I face is that when I create a delete button inside the gallery item as below, it does not delete the item that I intended it to.

 

 

Remove(ServerCollection,ThisItem)

 

 

For example, in the image attached, I created 5 items in the repeating table

The items are only saved and patched to the ServerCollection when I click save, and the form is then submitted and all data is patched to Sharepoint.

If i click delete on row 4, it is not guaranteed that row 4 is deleted. while it's pretty random, Mostly row 2 gets deleted first, then 3 etc. If I delete row 1, row 1 is successfully deleted.

 

Where did I go wrong here? Is it possibly because I have not yet patched items into the collection yet?

How can I ensure that I can delete the correct items in the gallery before patching it?

 

Thank you!

Categories:
I have the same question (0)
  • AshwiniBhandari Profile Picture
    97 on at

    Did you try this one - 

     

    On the Delete put this formula on OnSelelect:
     Remove(Datasource,LookUp(Datasource,ID=ThisItem.ID))

     

    (tried this for SharePoint list item directly and it works, not entirely sure if it holds true for collection too)

  • dchiu Profile Picture
    14 on at

    @AshwiniBhandari

    Sorry if I used the wrong term. It's not a editable table, but a repeating table. So I don't want to delete the item in sharepoint.

     

    What I would like to achieve is option to delete the items that I am creating it in the gallery, before adding it to the sharepoint list.

    Lets say I've made a mistake, and don't need this line item anymore. 

    Your formula is intended to delete the item from the source sharepoint I think (like an editable table) so that's not what I'm looking for.

     

  • SafaK Profile Picture
    62 on at

    Hi,
    Have you tried this function :  RemoveIf(ServerCollection, ID = ThisItem.ID)

    This should work

  • dchiu Profile Picture
    14 on at

    @SafaK 

    I just tried this code

    RemoveIf(ServerCollection, LineMoniS = ThisItem.LineMoniS)

    LineMoniS is the first cell on the left.

    Now it just deletes the whole collection when I press the delete icon (I attached a gif of its behavior)

     

    Originally with the below code, my rows were deleting at random (ish).

    Remove(ServerCollection, ThisItem)

     For some reason with the same code, now it is consistently deleting the top row first (I also inserted a gif to show this)

     

    I'm really not sure where I went wrong and what I need to fix here.

  • bkeano Profile Picture
    136 on at

    Hi @SafaK 

    Did you solve this issue? I'm getting excatly the same scenario

     

    Thanks

  • MrShivam Profile Picture
    72 on at

    @dchiu did you solve this issue? I am getting the same issue

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @dchiu 

    When you create the collection that is the datasource of your gallery, leave the original ID as a field and show it in a label on each row.  To make sure that the trashcan icon is inside the gallery, make its visible property ThisItem.IsSelected  It is not necessary to assign the ID column as this is created by SharePoint when the record is saved.    Select(Parent);Remove(ServerCollection, ThisItem) should work.

  • MrShivam Profile Picture
    72 on at

    Hi, @Drrickryp  When i try to delete a row , its always delete the first row 

    Screenshot 2022-05-08 at 8.09.16 PM.png

  • Verified answer
    VasuNo1 Profile Picture
    20 on at

    Solved:

    It turns out that collections do not have an "ID" column automatically set. 

     

    I added an ID column that automatically sets an ID using the GUID function:

    ClearCollect(tblMaterials,{Description:"",Qty:"",Unit:"",GUID:GUID()});

    VasuNo1_0-1669389295595.png

    Then I put this formula as the OnSelect Property of the Trash Icon I'm using: 

    Remove(tblMaterials,LookUp(tblMaterials,GUID=ThisItem.GUID));

     

    Its working well now.

     

  • PaulUK86 Profile Picture
    43 on at

    This problem was driving me crazy and this was the only solution from many that worked. Thank you!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard