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

Update a quantity column in a collection when the same item is seletced

Hi

I have screen where I have a dropdown and a Quantity text field and a ADD button. I should select  a vlaue from the drop down and enter the quantity in the text field when i click on the add button is should be added to the collection.

 

If I select the same product and enter the quatity it is been created as a new record in thr collection. Instead it sould increament the quantity.

 

Please assist in achieveing this.

15 REPLIES 15
Highlighted

Hi

This should not be a problem because you'll patch the collection only if the selected item exists in the collection (which means the collection exists).  

Have you tried to run the app ?

 

Théo

Highlighted

@Drrickryp

 

If(!IsBlank(QtyTextInput) && Value(QtyTextInput.Text)>0,
Collect(cProduct,{Item:DataCardValue1.Selected.Title,Qty:Value(QtyTextInput.Text),ItemID:DataCardValue1.Selected.ID}),
false);Reset(QtyTextInput)

This is the current formula I have been using. I haven't applied any increment in this formula

 

Note: There is no existing collection. The collection will be created and items will be added on the button click.

 

 

Highlighted

HI @tchin-nin

 

The formula gives an error on button.

The error doesn't allow the button to respondSmiley Sad

Highlighted

Can you try this ?

 

UpdateContext({selectedItem: LookUp(selectitems,id = Dropdown2.Selected.id)});
If(!IsBlank(selectedItem), 
Update(selectitems, 
selectedItem,
{id: Dropdown2.Selected.id,
title: Dropdown2.Selected.title,

qty: selectedItem.qty + Value(TextInput2.Text)}),
Collect(selectitems,
{id: Dropdown2.Selected.id,
title: Dropdown2.Selected.title,
qty: Value(TextInput2.Text)}))

 

Théo

View solution in original post

Highlighted

HI @tchin-nin@Drrickryp

 

Is there a possibility that if we select the existing item in a collection, the old item should be removed from the collection and new item should be updated as a new record in the collection.

 

Please assist me

Highlighted

@tchin-nin

 

This worked like a charmSmiley Happy

Now I can play around with what I need.

 

Thank you so much for the assistance.

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 (10,024)