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"));


Any ideas?

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

Try this formula:

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

Documentation: Select function in Power Apps

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

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.


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, privacy policy and cookie policy

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