Showing results for 
Search instead for 
Did you mean: 
Helper IV
Helper IV

Update all Items from a Gallery on button Click



I'm trying to build a button that will cancel an order and return all the stock that was booked out on the order back to the stock available column.


I have this work if the user returns each item using the below:

UpdateIf('Resource Centre Inventory v5', ID = ThisItem.ProductID, {StockAvailability: LookUp('Resource Centre Inventory v5',ID = ThisItem.ProductID).StockAvailability + ThisItem.QTY})


But i can't work out how to change the above to loop through all items in a gallery and return stock.  I've tried swapping the ThisItem.production to Gallery_5.Selected but obviously this only does the first item/selected. I tried adding the order into a collection but i can't seem to match the ID with the master database Resource Centre Inventory. 


Any help would be really great.



Accepted Solutions

Hi @mousman85 ,

Try inserting these two pieces to replace what is there

   Gallery5_1.AllItems as aPatch,
      'Resource Centre Inventory v5',
         aPatch.QTY + 
            'Resource Centre Inventory v5', 
            ID = aPatch.ID
   Gallery5_1.AllItems as aDel, 
      'RC Ordered Items', 
      OrderID = aDel.ID


Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Super User
Super User

Please try with the Collection, You need to have the Product ID also stored in the collection. When a new item is added in the Order grid the same has to go to Collection, Likewise when order is loaded or opened, on the screen load you need to store the grid values to the Collection by clearing it. By doing so, you will always have the Collection with latest order related products in it.


If you find my solution helpful for resolving the issue, then please consider Accept it as the solution to help the other members find it more quickly.

- Architect Madhan

Please click the "Accept as Solution" button and give thumbs up, if it is helpful to you.

I tried to add the order items in to a table: 

set(colItemsOrdered, gallery5_1.allitems)

 But when  i tried to match the colItemsorder.ProductID with the ID in inverntory management, i get an error on using = that says it can't compare a Number to a table?

hi @mousman85 


Try this please 



    Title =ThisItem.SKU,
    {'Quantity On Hand': 'Quantity On Hand'   +  Value(DDAmountCart.Selected.Value)}

Please change to your data source and control names







Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.


I have this working for items so the remove sits within the gallery that is fine. But what i need is one overall button that cancels the entire order that doesn't sit within the gallery. So i don't think the above will work for what I need as I can't reference an ThisItem as its not in the gallery. Below is my page layout, the cancal order button is where i have the issue, it can delete everything and return stock but it only returns the first item in Gallery 5_1.:


Hi @mousman85 

Do you want to remove and return stock, already saved data ?

Do you need to delete all its in the gallery and return to stock or One by one ?




Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.
Solution Sage
Solution Sage

So what you need is a ForAll( to grab the the ProductID from the ordered item gallery, and using that as input to restock the inventory?

Super User
Super User

Be careful using UpdateIf, I believe it is non-delegable so your logic to update your quantity onhand will fail if the relevant row is not within the first 500 to 2000 (depending on the value of delegation limit in settings).

Also be wary that if your loop fails mid way through processing your data (or only finds/updates some records because of delegation issues), your data could be left in an inconsistent state (e.g. some but not all of records  get updated). This is where the value of transactions and stored procedures comes in with SQL (you can ensure that either the complete 'set' of updates succeeds or none of them do) but given the additional licensing costs of using Power Apps with SQL, you may be willing to accept that risk.

Hi @mousman85 


Try this please as this code will delete all item in the gallery 




    Remove('IT Equipment Orders', LookUp('IT Equipment Orders', ID= Value(  lblID.Text))))




Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

I need to remove and return the stock that's already saved. I have a button to be able to return one by one if the user needs. 

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

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 (4,374)