cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

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 @Anonymous 

 

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

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.
Anonymous
Not applicable

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

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,664)