cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: ForAll update value on each row in collection

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
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: ForAll update value on each row in collection

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
Check this Out

Announcing

Class of 2020- Season 2

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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