Hello PowerApps Community 🙂
I am building an online shopping car. I'm using a Collection to collect the items and then patching them to a SharePoint List. There is an Inventory number field in SharePoint that I would like reduced by the number of items (Qty) selected inside the Collection.
Collection = colMyOrder
SharePoint List = 'Company Store'
Inventory Column in SharePoint = 'Inventory'
Gallery = galProducts
CurrentInventory_Lbl = a Label that contains the Inventory number from SharePoint
Qty = a variable that has the number of inventory to be checked out from the Collection (which must be subtracted from the CurrentInventory)
Here is my current code:
ForAll(
colMyOrder,
Patch(
'Company Store',
galProducts.Selected,
{'Inventory (Inventory0)': Value(CurrentInventory_Lbl.Text) - Qty}
)
);
The issue:
This code works fine when I only check out 1 item from the Collection. The Inventory field is SharePoint is subtracted correctly. The issue is when I check out multiple items! When I do so, only the last Inventory field is updated whereas the other items stay the same
Example:
If I checked out 5x PENCILS, 2x DESKS, 7 ERASERS, the only Inventory in SharePoint that will be updated is the ERASERS because it is the last one to be added to the collection
If there is a way to make sure all inventory fields in SharePoint are updated, that would be much appreciated!
Thanks much as always and appreciate all the value that this community provides.
Cheers,
Andy