Hi,
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.
Thanks
Solved! Go to Solution.
Hi @mousman85 ,
Try inserting these two pieces to replace what is there
ForAll(
Gallery5_1.AllItems as aPatch,
Patch(
'Resource Centre Inventory v5',
{ID:aPatch.ID},
{
StockAvailability:
aPatch.QTY +
LookUp(
'Resource Centre Inventory v5',
ID = aPatch.ID
).StockAvailability
}
)
);
ForAll(
Gallery5_1.AllItems as aDel,
RemoveIf(
'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.
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.
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
Remove(CartList,ThisItem);UpdateIf(
ProductServiceList,
Title =ThisItem.SKU,
{'Quantity On Hand': 'Quantity On Hand' + Value(DDAmountCart.Selected.Value)}
)
Please change to your data source and control names
Hi,
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 ?
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?
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
ForAll(Gallery14.AllItems,
Remove('IT Equipment Orders', LookUp('IT Equipment Orders', ID= Value( lblID.Text))))
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.