cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Remove ThisItem in Collection not working

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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!

View solution in original post

8 REPLIES 8
Highlighted
Super User III
Super User III

@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."

Community Support
Community Support

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 didnt 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 gallerys items property is?

Secondly, here is my test for your reference:

1\add a gallery and set its item property to:

 

ColIrrParts

 

2\ add a trash can icon into the gallery and set its 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

Highlighted

@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.

Highlighted

@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."

Highlighted

@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."

Highlighted

@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.

Highlighted

@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.

Highlighted

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!

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (15,936)