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.
This was the only solution that worked for me.
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!
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.
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.
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."
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."
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.
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)
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
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."
WarrenBelz
93
Most Valuable Professional
MS.Ragavendar
60
stampcoin
48