cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
azeesdinu43
Helper II
Helper II

Patch - Collection

I have collection  like below.  I have row number added while adding new item to that collection. 

If I have 5 items in my collections, If I delete 3rd Item, I wanted to reorder the RowNumber again. Since Order will be changed like (1,2,4,5) when deleting in-between any rows. 

Kindly let me know how to update the collection while deleting any row.

 

Collect(myCollection,
{
Id: Text(GUID()),
Column1:"",
Column2:"",
RowNumber: CountRows(myCollection)+1
});
13 REPLIES 13

Hi, 

I think this will not work.. 

Ex : 1,2,3,4,5  If I delete RowNumber 1 then update collectiong using UpdateIf my row will be like that ...1,3,4,5 but I want 1,2,3,4

Hi @azeesdinu43 

 

I tested the code @Pstork1 provided and works fine for RowNumber 1 as well. Same code but Used Datasource instead of a collection.

 

Below code when removing the item from the gallery.

 

Set(currentrow,BrowseGallery1.Selected.RowNumber);
Remove('Desk Reservation',LookUp('Desk Reservation',RowNumber=BrowseGallery1.Selected.RowNumber));
UpdateIf('Desk Reservation',RowNumber > currentrow,{RowNumber: RowNumber -1});

 

StalinPonnusamy_0-1635045774052.png

 

 
Thanks,
Stalin - Learn To Illuminate

Pstork1
Dual Super User III
Dual Super User III

No, if you delete RowNumber 1 then it will update everything with a rowNumber greater than 1.  Which would be 2,3,4,5.  They would become 1,2,3,4.  It will also work if you delete RowNumber 5 because the Update won't do anything since no RowNumber is greater than 5.  UpdateIf() will go through the whole collection and update all the records that meet the criteria.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Yes, Your are right. Its working. I compared with Equal but It's suppose to be Greater than and Equal

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,430)