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

Re: Collection regenerating sequence number

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
Highlighted
Community Support
Community Support

Re: Collection regenerating sequence number

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

Highlighted
New Member

Re: Collection regenerating sequence number

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,579)