web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collection regeneratin...
Power Apps
Answered

Collection regenerating sequence number

(0) ShareShare
ReportReport
Posted on by 4

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)

Untitled1.png
Untitled2.png
Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    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

  • chow0724 Profile Picture
    4 on at

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard