cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kudo Kingpin
Kudo Kingpin

ForAll update value on each row in collection

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.   

1 ACCEPTED SOLUTION

Accepted Solutions
Kudo Kingpin
Kudo Kingpin

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}))

 

View solution in original post

1 REPLY 1
Kudo Kingpin
Kudo Kingpin

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}))

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,855)