cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Collection regenerating sequence number

Hi Community, 

 

I've the simple collection which will increasing and index, which currently is working fine.

 

I have the function for the delete the row of the collection, which the sequence number need to regenerate it, how to regenerate the sequence of the number?

 

Below are the code i use:

OnVisible:

ClearCollect(AssetCollection,{LineItem:"Notebook",LineSerialNumber:"",LineSignOutRemarks:"",LineReturnRemarks:"",LineIndex:Value(Last(AssetCollection).LineIndex)


Add Row:

Collect(AssetCollection,{LineItem:"Notebook",LineSignOutRemarks:"",LineReturnRemarks:"",LineIndex:Value(Last(AssetCollection).LineIndex)+1});

Remove Row in Gallery:

Remove(AssetCollection,ThisItem)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @chow0724 :

Do you want to regenerate the LineIndex field based on the deleted record?

This function can be achieved through the updateIf function:

Remove Row in Gallery:

 

UpdateIf(AssetCollection,LineIndex>ThisItem.LineIndex,{LineIndex:LineIndex-1});Remove(AssetCollection,ThisItem);

 

15.gif

I think this link will help you a lot:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

Best Regards,

Bof

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @chow0724 :

Do you want to regenerate the LineIndex field based on the deleted record?

This function can be achieved through the updateIf function:

Remove Row in Gallery:

 

UpdateIf(AssetCollection,LineIndex>ThisItem.LineIndex,{LineIndex:LineIndex-1});Remove(AssetCollection,ThisItem);

 

15.gif

I think this link will help you a lot:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

Best Regards,

Bof

View solution in original post

@v-bofeng-msft it worked! thanks for providing the solution, will also explore the update if function

Helpful resources

Announcements
News & Announcements

Community Blog

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

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,720)