Hi all,
I've encountered a rather odd (and inconsistent) issue when removing items from a collection.
Here's my scenario:
- I have a gallery connected to a SharePoint list with about ~3000 items. The gallery items can be filtered by selecting some preset values or by using a text input field to search.
- Each gallery item has a checkbox. When the checkbox is selected, the item will be added to a collection. The contents of the collection are displayed in a second gallery on the right side of the screen.
- To prevent users from having to select numerous records manually, I have a checkbox outside the gallery that will enable users to select all items currently shown in the gallery. When the checkbox is unchecked, all items currently displayed in the gallery should be removed from the collection.
Often this works as intended, but occasionally the unchecking the check-all checkbox removes the wrong item from the collection.
Here I've got 5 records currently in my collection. I've just added record 2238 by checking the checkbox outside of the gallery.
I uncheck the checkbox, but the item currently shown in my gallery is still selected and is still part of the collection. The OnUncheck action has removed the first item of the collection (record 537) instead of record 2238.
I toggle the checkbox again--again the OnUncheck action has removed the first item in my collection (1648), but still hasn't gotten rid of the item shown in my gallery (2238).
Here's the checkbox's OnUncheck configuration:
ForAll(
gallery_ItemSelection.AllItems,
Remove(
collection_CurrentlySelectedItems,
LookUp(
collection_CurrentlySelectedItems,
ID = ThisRecord.ID
)
)
)
I'm finding this behavior very confusing, as I'm targeting the item in the collection by its unique ID. I've also tried a few variations on looking up the item from the collection (LookUp, Filter(First()))--but the problem persists. It seems like the ForAll function is caching the IDs of the previously selected records even though they are no longer displayed in the gallery.
Has anyone seen anything like this before? Thank you!