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 / Sequence number in Tex...
Power Apps
Unanswered

Sequence number in Text field Powerapp

(0) ShareShare
ReportReport
Posted on by 3

Hello 

Set(varNextNumber, 1);
ClearCollect(
colGeneratedApplicationNumbers,
{
Value: "2023-ADM-0001"
}
);
UpdateContext({ varNextNumber: varNextNumber + 1 });
Collect(
colGeneratedApplicationNumbers,
{
Value: Concatenate(Year(Now()), "-ADM-", Text(varNextNumber, "0000"))
}
);
UpdateContext({ varNextNumber: varNextNumber});



I would like to have a field in my Power Apps form that automatically generates a sequence number when a new record is created. The sequence number should be based on the last submitted number in a SharePoint list and incremented by 1. This means that each time a new record is entered and saved in the SharePoint list, the sequence number should automatically increase to assign a unique number to the new entry.

Thank you in Advance



Categories:
  • victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    Use this to get the last created item number +1:

     

    Set(
     vLastNumber,
     Value(Coalesce(Match(Last(ShP_List).ShP_Column, "(?<=-ADM-)\d+").FullMatch,0))+1
    )

     

     

    I hope it helps 🙂

  • charlesaighine Profile Picture
    3 on at

    Hello, I have managed to find an alternative solution that works perfectly for my needs. Thank you so much for your assistance. I truly appreciate your prompt reply.

    I used this code:

    Set(VarIncre,First(Sort('Asset Manager - Submitted Applications',ID,SortOrder.Descending).ID));


    ClearCollect(
    colGeneratedApplicationNumbers,
    {Value: Concatenate(Year(Now()), "-ADM-",VarIncre.ID-334)}
    );


    Then I put this code inside the Textfield: 

    Last(colGeneratedApplicationNumbers).Value
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @victorcp 

    I tried your suggestion, but received an error

    Code: 

    Set(vLastNumber;Value(Coalesce(Match(Last(Internordre).OrdNo;"(?<=-IN-)\d+").FullMatch;0))+1)
    Error: 
    The behavior function in a non-behavior property. You cannot use this property to change values ​​elsewhere in the app
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I tested your suggestion, but got an error

    The formula is registered in Text properties of an textbox field in a gallery

     

    Engalpengal2009_1-1708695949061.png

     

     

  • victorcp Profile Picture
    2,350 Moderator on at

    Sorry I thought you are using this code in a button.

     

    in this case try this:

    Value(Coalesce(Match(Last(Internordre).OrdNo;"(?<=-IN-)\d+").FullMatch;0))+1

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @victorcp So no errors, and thats good. But it dosnt show the "INT" in front of the serial number.

    And is it possible to set a minimum amount digit to start with? ex. INT00000012 (8 digit)

     

    Engalpengal2009_0-1708938261220.png

     

    Source - Internordre

    Engalpengal2009_1-1708938352584.png

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Next number generated should be INT00000002

  • victorcp Profile Picture
    2,350 Moderator on at

    As the OrdNo changed format, it will be easier like this:

    With(
     {vNumberOfDigits: 8},
     
     With(
     {vOrdNo: Value(Right(Last(Internordre).OrdNo,vNumberOfDigits))},
    
     "INT" & 
     Concat(Sequence(vNumberOfDigits-Len(Text(vOrdNo))),"0")
     & vOrdNo
     )
    )

     I hope it helps 🙂

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    The code works now, but it cant find the next correct serialnumber. Is it because the column is in text format? 

  • victorcp Profile Picture
    2,350 Moderator on at

    oh sorry, I forgot to add 1 in the code:

    With(
     {vNumberOfDigits: 8},
     
     With(
     {vOrdNo: Value(Right(Last(Internordre).OrdNo,vNumberOfDigits))+1},
    
     "INT" & 
     Concat(Sequence(vNumberOfDigits-Len(Text(vOrdNo))),"0")
     & vOrdNo
     )
    )

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard