cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Seanan
Regular Visitor

Updating multiple records in a collection

Hi all,

 

I apologise if this has already been solved in another post, however I haven't managed to have any luck with my own app as of yet.

 

I currently have a shopping cart app that is linked to a SharePoint List.

Seanan_0-1649865109805.png

The issue I am having is with the collection. When the quantity of an item increases the price in the collection should changes (As shown in the text field £400 x Qty: 2). The code I am using to display the correct price in the label is:

"£" & ThisItem.Price*Value(TextInput2.Text) & " x" & " Qty: "

However, I update the collection in the + and - buttons. The code for this is as follows:

Update(ColProductOrder, ThisItem, {Qty:ThisItem.Qty + 1,Name:ThisItem.Name,Brand:ThisItem.Brand,Colour:ThisItem.Colour,Size:ThisItem.Size,Image:ThisItem.Image,Price:ThisItem.Price},All);

In the Update function I have tried

Price:ThisItem.Price * ThisItem.Qty
Price:ThisItem.Price*Value(TextInput2.Text)

and neither worked. Instead it would just double the number, for example: £200, 400, 800, 1600 etc.

 

Would anyone be able to help me with this issue?

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @Seanan,

Do you want to update the Price for the current item based on the quantity changes?

Could you please share a bit more about your scenario?

 

If you use the increase button to patch the price and increase the quantity at the same time, I think there will be a delay for the real price. The Patch() function could not capture the real quantity when doing the calculation.

 

To achieve your need, I think you should add another new button to update the price, or you could choose the Timer control to minimize the delay.

vqiaqimsft_0-1650005879241.png

 

Patch(ColProductOrder,ThisItem,{Price:ThisItem.Price*ThisItem.Qty})

 

vqiaqimsft_1-1650005911537.png

Patch(ColProductOrder,ThisItem,{Qty:ThisItem.Qty+1});

 

Here is a good template from Matthew Devaney that could help you.

Build A Shopping Cart In Power Apps (matthewdevaney.com)

Best Regards,
Qi

View solution in original post

1 REPLY 1
v-qiaqi-msft
Community Support
Community Support

Hi @Seanan,

Do you want to update the Price for the current item based on the quantity changes?

Could you please share a bit more about your scenario?

 

If you use the increase button to patch the price and increase the quantity at the same time, I think there will be a delay for the real price. The Patch() function could not capture the real quantity when doing the calculation.

 

To achieve your need, I think you should add another new button to update the price, or you could choose the Timer control to minimize the delay.

vqiaqimsft_0-1650005879241.png

 

Patch(ColProductOrder,ThisItem,{Price:ThisItem.Price*ThisItem.Qty})

 

vqiaqimsft_1-1650005911537.png

Patch(ColProductOrder,ThisItem,{Qty:ThisItem.Qty+1});

 

Here is a good template from Matthew Devaney that could help you.

Build A Shopping Cart In Power Apps (matthewdevaney.com)

Best Regards,
Qi

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.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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 (3,632)