Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 50ajzdKmOQQhVMrM1m0JEj
Power Apps - Building Power Apps
Answered

Remove ThisItem in Collection not working

Like (0) ShareShare
ReportReport
Posted on 26 Mar 2020 23:00:27 by 47

I have an app with a shopping cart using a collection (ColIrrParts) in a gallery (GalleryPartsCart). I have a trash can icon in my gallery with the OnSelect set to: Remove(ColIrrParts,ThisItem)

 

This only removes the first item in the collection and will not work for removing any other items in the collection. I cannot figure out why the remove function will not work properly. I wonder if it may be because I have added a TextInput in the gallery.

 

Here is the information on TextInput:

The TextInput Default is set to: ThisItem.Quantity

The TextInput OnSelect is set to: Select(Parent)

The TextInput OnChange is set to: Patch(ColIrrParts, GalleryPartsCart.Selected, {Quantity: TextInputQuantity.Text,Total: LabelItemTotal.Text});
Reset(TextInputPartsTotal)

 

It may not be related to the TextInput at all. Just cannot figure out this otherwise simple issue.

  • srose Profile Picture
    94 on 11 Mar 2021 at 15:48:11
    Re: Remove ThisItem in Collection not working

    This was the only solution that worked for me.

  • Verified answer
    Nate0173 Profile Picture
    47 on 28 Mar 2020 at 01:43:24
    Re: Remove ThisItem in Collection not working

    I ended up making a duplicate of the app screen and deleting the original screen. Now it seems to be working fine. I never did figure out why it wouldn't work properly especially considering I used a duplicate of the screen and it works.

     

    Thank you @mdevaney  and @v-bofeng-msft  for taking time to look into this!

  • Nate0173 Profile Picture
    47 on 27 Mar 2020 at 20:15:07
    Re: Remove ThisItem in Collection not working

    @v-bofeng-msft 

    I tried the solution @mdevaney  suggested and it doesn't work. You can see my explanation in my reply. It seems to revolve around my formulas outside the gallery. The "Remove" function works fine until adding formulas outside the gallery that ask for information within the gallery.

  • Nate0173 Profile Picture
    47 on 27 Mar 2020 at 18:08:00
    Re: Remove ThisItem in Collection not working

    @mdevaney 

    That doesn't seem to work either. I found that it stops working when entering formulas outside the gallery using information inside the gallery. The three formulasI have are:

     

    TextInputPrice: Text set at: Text((If(Sum(ColIrrParts,Total)<.001,0,Text(Sum(GalleryPartsCart.AllItems,LabelItemPrice)))),"[$-en-US]$#,###.00")

    TextInputTaxTotal: Default set at: Text((RoundUp(((TextInputPrice+TextInputLaborTotal)*(TextInputTaxPercentage/100)),2)),"[$-en-US]$#,###.00")

    TextInputTotalAmount: Default set at: Text((TextInputPrice+TextInputLaborTotal+TextInputTaxTotal),"[$-en-US]$#,###.00")

     

    The "Remove" function worked fine until entering the formulas. It stopped once when entering in the first formula for TextInputPrice. I rebuilt the gallery and tried again. The second time it still worked after entering the TextInputPrice formula, but stopped after entering in the TextInputTaxTotal formula. Once it stops working, it will not work again even when I delete all formulas from all these TextInput fields. I have to rebuild the gallery again. There is something with these formulas that the "Remove" function doesn't like.

  • mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 27 Mar 2020 at 17:48:32
    Re: Remove ThisItem in Collection not working

    @Nate0173 

    OK, that error means ID does not exist as a column in the collection.  I thought maybe you brought in some data from SharePoint which always has an ID column.

     

    Lets try something else.  How about this...

     

    Remove(ColIrrParts, Gallery1.Selected)

     

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 27 Mar 2020 at 17:48:08
    Re: Remove ThisItem in Collection not working

    @Nate0173 

    OK, that error means ID does not exist as a column in the collection.  I thought maybe you brought in some data from SharePoint which always has an ID column.

     

    Lets try something else.  How about this...

    Remove(ColIrrParts, Gallery1.Selected)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Nate0173 Profile Picture
    47 on 27 Mar 2020 at 15:16:58
    Re: Remove ThisItem in Collection not working

    @mdevaney 

    I tried that code also and I get the error, "Name isn't valid. this identifier isn't recognized." referring to "ID" in both locations.

  • v-bofeng-msft Profile Picture
    on 27 Mar 2020 at 09:44:56
    Re: Remove ThisItem in Collection not working

    Hi  @Nate0173 ďĽš

    Firstly,I made a similar test but did not encounter the problem you described.

    I also did the test you described about the TextInput control, and I didn’t encounter any problems. The problem should have nothing to do with the TextInput control.

    Since there is a situation where only the first record can be deleted, I guess that the "thisitem" might points to the wrong address. It may be related to your gallery settings.

    Can you tell me what the gallery’s items property is?

    Secondly, here is my test for your reference:

    1\add a gallery and set it’s item property to:

     

    ColIrrParts

     

    2\ add a trash can icon into the gallery and set it’s item property to:

     

    Remove(ColIrrParts,ThisItem)

     

     

    1.jpg2.jpg3.png

     
     

    Finally, Thanks for @mdevaney â€™s solution, I think this is a good way to solve your problem. Have you tried it? Did you succeed?

    Best Regards,

    Bof

  • mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 27 Mar 2020 at 01:16:09
    Re: Remove ThisItem in Collection not working

    @Nate0173 

    I wonder if you could make a simple fix by changing your code to this:

    Remove(ColIrrParts,LookUp(ColIrrParts, ID = ThisItem.ID))

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 60

#3
stampcoin Profile Picture

stampcoin 48

Overall leaderboard