1

I've got a gallery on the screen with a text input field. When the value of the input field changes, I want to update the selected item with the new value but PATCH just keeps adding rows to the collection. I've got similar code on other screens that's working properly.

Patch(colAvailableItems, galNewOrder.Selected, {Qty: Value(txtNewOrderQty.Text)} );

The code to create the collection is on a button on a previous screen-

ClearCollect(datAvailableItems,'05bGetSkusForNewOrder'.Run(radProductType.Selected.Value, ddStore.Selected.LocationID, ddWeekNum.Selected.DeliveryDate, ddWeekNum.Selected.FiscalWeek, ddWeekNum.Selected.DistPOLocationID, ddWeekNum.Selected.OrderOnDate));

ClearCollect(colAvailableItems, RenameColumns(AddColumns(datAvailableItems, "Qty", 0, "Pieces", ThisRecord.BUM * "Qty"),"BUM", "CsPk"));

Navigate(storeNewOrder);

Any ideas?

2
  • Is your text input control inside the gallery control? Also, the same collection (colAvailableItems) is added to items property of gallery? Commented May 27, 2021 at 18:49
  • Yes, to both of your questions.
    – Chris G.
    Commented May 27, 2021 at 19:07

3 Answers 3

0

Try this formula:

Select(Parent);
Patch(colAvailableItems, galNewOrder.Selected, {Qty: Value(txtNewOrderQty.Text)} );

Documentation: Select function in Power Apps

1
  • It still just adds rows containing the value to the collection.
    – Chris G.
    Commented May 27, 2021 at 19:08
0

Not sure if it's the best way but it appears to be working. I'm using UpdateIf in lieu of PATCH, like so...

UpdateIf( colAvailableItems, (Qty = 0 && ExternalProductID = ThisItem.ExternalProductID), { Qty: Value(galNewOrderItems.Selected.txtNewOrderQty.Text) } )

No new rows getting added to the collection and the data is being written to the db properly.

0

Another way is to use LOOKUP in the Patch command to a unique identifier on the item.

Patch('DatasourceName', LookUp('DataSourceName', id = something.Selected.id), {NORMAL PATCH PARAMETERS })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.