cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
as733y
Helper III
Helper III

Patch(), UpdateIf() for updating quantity in a Shopping Cart App?

I have a collection called ShoppingCart with Product, Size, and Quantity.

 

How do I increase the quantity if someone adds the same size shirt?

 

Below is the code for the OnSelect button and is increasing the quantity correctly, but will create another record. How do I get it to just update the record?

 

UpdateIf(ShoppingCart, Product = DataGallery.Selected.Title && Size = SizeDropdown.Selected.Result, {Quantity: Quantity+1}); Collect(ShoppingCart, {Product: DataGallery.Selected.Title, Size: SizeDropdown.Selected.Result, Pics: DataGallery.Selected.Pics, Quantity: 1})

 

 

3 REPLIES 3
RandyHayes
Super User
Super User

@as733y 

UpdateIf will not create a record, so there is something else going on in your app if you are seeing a new record created.

I would utilize the monitor tool to start with and see what is going on at the point that you click the button.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

 

@RandyHayes Below is the screenshot of the Monitor tool. I'm not entirely sure how to read this, but can you tell from this screenshot?

as733y_2-1647542239237.png

 

RandyHayes
Super User
Super User

@as733y 

So it looks like in that picture that you pressed on a button three times.

The best thing to do is to prepare your app for that point in which you are just about to click the button, then go to the monitor tool and clear the data, then click on the button and see what actions it took.

It does appear though that it is only one row that it is working with, but, since there are multiple actions in that photo, it is hard to tell.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,382)