
Announcements
I have a collection where it captures the row number displayed in a gallery. If one row is deleted, I want to adjust the row number accordingly.
Current formula that applies the row number (in a text box):
If(!IsBlank(ComboBox2.SelectedItems) && !IsBlank(ComboBox1.Selected), Patch(ReviewerCollection, ThisItem, {LineOrder: If(!IsBlank(txtOrder.Text), txtOrder.Text, CountRows(ReviewerCollection))}),If(!IsBlank(ComboBox1.Selected), Patch(ReviewerCollection, ThisItem, {LineOrder:txtOrder.Text}))))Result in LineOrder column is 1, 2, 3, 4...
But when row 2 is deleted, the LineOrder column is 1,3,4... I want to be able to use ForAll (or UpdateIf) in order to adjust the LineOrder accordingly to 1,2,3. It sounds easy but I can't figure out what function to use.
Finally figured this out using below formula on OnSelect property of the delete icon.
Remove(ReviewerCollection, ThisItem);
Clear(Counter);
ForAll(ReviewerCollection, Collect(Counter, {RowNum: CountRows(Counter)+1, RowNumOld: Value(LineOrder)}));
ForAll(Counter, Patch(ReviewerCollection, First(Filter(ReviewerCollection, Value(LineOrder)=RowNumOld)), {LineOrder:RowNum}))