cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Patch a collection with items inputted in a Gallery of the same collection

Hello, 

 

I am doing an application for adding products to a cart for then being able to quote them. I want users to be able to apply discounts on their items and then being able to calculate a final price. 

 

When items are added to the cart, the columns "Discount" and "FinalPrice" are added with a price of 0.

 

I would like a button that when users enter a discount value inside each item within a gallery, the final price and discount could be saved back to the collection items. 

 

For example: 

 

image.pngI would like that when the users input a discount, like [50], and click on apply, the final price for the first item to be of 2300.

 

And with the same apply action the final price of the second item to remain as the list price 2300 because of a discount of 0.

 

 

 

 

 

 

 

 

 

Currently I try it with the formula: 

Patch(Courses_Package_Collection,Defaults(Courses_Package_Collection),{Discount: Value(Unitary_discount_input.Text),FinalPrice: ListPrice - (ListPrice * Unitary_discount_input)})

Of course nothing good happened... first because the ListPrice Value I want to use that is a value already from the collection gives and error. And second this would just create another item in the collection, it wouldn't edit nothing. 

 

Please help!!

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

Hi @Anonymous 

The Patch() function contains three elements, the datasource being patched, the record being patched, and the fields in that record being patched. 

To add a NEW record to the datasource (this could be a SharePoint list or a Collection), you use Defaults(datasource) as the second element.  Defaults() means that a new record is being added. 

To patch an existing record from within the gallery, you would use 

 

Patch(Courses_Package_Collection,ThisItem,{...

 

as the OnSelect property of an icon inside of the gallery.

 To patch an existing record selected inside the gallery but from an icon outside of the gallery, you would use

 

Patch(Courses_Package_Collection,Lookup(Courses_Package_Collection,ID=Gallery1.Selected.ID),{...

 

as the OnSelect property of that icon.

  

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

Hi @Anonymous 

The Patch() function contains three elements, the datasource being patched, the record being patched, and the fields in that record being patched. 

To add a NEW record to the datasource (this could be a SharePoint list or a Collection), you use Defaults(datasource) as the second element.  Defaults() means that a new record is being added. 

To patch an existing record from within the gallery, you would use 

 

Patch(Courses_Package_Collection,ThisItem,{...

 

as the OnSelect property of an icon inside of the gallery.

 To patch an existing record selected inside the gallery but from an icon outside of the gallery, you would use

 

Patch(Courses_Package_Collection,Lookup(Courses_Package_Collection,ID=Gallery1.Selected.ID),{...

 

as the OnSelect property of that icon.

  

View solution in original post

Anonymous
Not applicable

That worked perfectly.

Kind regards from my beautiful Costa Rica!!

Drrickryp
Super User
Super User

You are quite welcome.You are quite welcome.

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,964)