
Announcements
Howdy, I have a gallery that shows a collection from a table. What I'm trying to do is when a user updates the order of their favorites list, that it updates the sort order field. For instance, they want number 1 to be number 4 or when an item is deleted to order them correctly. It is a multi-user system & Each has their own list of favorites.
I create the collection based on what is found in the table & using with "with" to add a row number. This is how I create the collection from the tbl_FavoriteLinks table...
ClearCollect(FavCollection,
With({records:
SortByColumns(Filter(
tbl_FavoriteLinks,
UserID.Email = varUserEmail
),"cr647_sortorder",SortOrder.Ascending)},ForAll(Sequence(CountRows(records)),Patch(Last(FirstN(records,Value)), {rowNumber: Value})))
)
Collection name: FavCollection
Datasource: tbl_FavoriteLinks
Key: FavoriteID
Update all records in FavCollection where ID match Field to update is SortOrder to rowNumber is in the collection
I've tried using ForAll...
ForAll(
FavCollection,
Patch(tbl_FavoriteLinks,
tbl_FavoriteLinks, FavoriteID = FavCollection[@FavoriteID], { SortOrder: rowNumber }
)
)I've tried suggestions from copilot & none of them work