Hello PowerApps Community,
*english is not my first language
I have an app that lists inventory and some data about each item. Its data source is a sharepoint list (biglist). I created a new screen to edit the list using 2 galleries: A(Inventory_Search_Gallery,biglist) - is to list all items and search in it. relevant columns are InventoryCount and Title
B(SelectedMaterialsGallery,SelectedMaterials) - is a collection created by OnSelect in gallery A. Gallery B is ment for editing in bulk spesific records . collect function is:
Collect(
SelectedMaterials,
{
ID: GUID(),// Generate a unique ID using the GUID() function
ItemName: Inventory_Search_Gallery.Selected.Title,
Quantity: Inventory_Search_Gallery.Selected.InventoryCount,
startQuantity: Inventory_Search_Gallery.Selected.InventoryCount,
ReadyToSave: false
}
)
In Gallery B I have some inputs, toggles and buttons to manage each record. I dont know if its relevant, but if it is ill share by request.
When editing is done I have a button to patch biglist that works fine but is lacking:
ForAll(
SelectedMaterials,
If(ThisRecord.ReadyToSave=false,
Notify("Please confirm for row " & ThisRecord.ItemName,NotificationType.Error),
Patch(
biglist,
LookUp(biglist, ItemName = ThisRecord.Title),
{ InventoryCount: ThisRecord.Quantity }
)
)
);
Clear(SelectedMaterials)
My problam is that SelectedMaterials clears even if an error is triggered. I want it to either: remove the success records (keeping the error records to be fixed) or not clear the collection.
So I tried to use bing for help. this is what i got: spoiler (powerapps give me an invalid argument for clearcollect)
ClearCollect(
ErrorRecords, // Initialize the ErrorRecords collection
ForAll(
SelectedMaterials, // Loop through each record in SelectedMaterials
If(
ThisRecord.ReadyToSave = false, // Check if ReadyToSave is false
Notify("Please confirm for row " & ThisRecord.ItemName, NotificationType.Error), // Show error message and add record to ErrorRecords
If(
!IsBlank(LookUp(biglist, ItemName = ThisRecord.Title)), // Check if record exists in biglist
Patch(
biglist, // Update the existing record in biglist
LookUp(biglist, ItemName = ThisRecord.Title),
{ InventoryCount: ThisRecord.Quantity }
)
)
)
)
);
If(
CountRows(ErrorRecords) = 0, // If no error records, clear SelectedMaterials
Clear(SelectedMaterials)
)
Any ideas?

Report
All responses (
Answers (