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 / Generate serial number...
Power Apps
Unanswered

Generate serial number in powerapp

(0) ShareShare
ReportReport
Posted on by 603

How to generate a six digit serial number in powerapps whenever a new item is submitted? Should I write power automate flow for the same? The serial number should be in format RAS001, RAS002, RAS003, etc

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    RAS followed by 3 digits limits you to 999 possible records before running out... are you sure thats long enough?

  • TheRobRush Profile Picture
    11,128 Moderator on at

    I would recommend something like this, where you have RAS followed by a randomized 6 digit alphanumeric code so it will be unique and wont run out of options for a very long time

    Concatenate("RAS",Concat(
    ForAll(
     Sequence(6),
     First(
     Sort(
     Table(
     {Var:"1", Val:Rand()}, {Var:"2", Val:Rand()}, {Var:"3", Val:Rand()},
     {Var:"4", Val:Rand()}, {Var:"5", Val:Rand()}, {Var:"6", Val:Rand()},
     {Var:"7", Val:Rand()}, {Var:"8", Val:Rand()}, {Var:"9", Val:Rand()},
     {Var:"0", Val:Rand()}, {Var:"A", Val:Rand()}, {Var:"B", Val:Rand()},
     {Var:"C", Val:Rand()}, {Var:"D", Val:Rand()}, {Var:"E", Val:Rand()},
     {Var:"F", Val:Rand()}, {Var:"G", Val:Rand()}, {Var:"H", Val:Rand()},
     {Var:"I", Val:Rand()}, {Var:"J", Val:Rand()}, {Var:"K", Val:Rand()},
     {Var:"L", Val:Rand()}, {Var:"M", Val:Rand()}, {Var:"N", Val:Rand()},
     {Var:"O", Val:Rand()}, {Var:"P", Val:Rand()}, {Var:"Q", Val:Rand()},
     {Var:"R", Val:Rand()}, {Var:"S", Val:Rand()}, {Var:"T", Val:Rand()},
     {Var:"U", Val:Rand()}, {Var:"V", Val:Rand()}, {Var:"W", Val:Rand()},
     {Var:"X", Val:Rand()}, {Var:"Y", Val:Rand()}, {Var:"Z", Val:Rand()}
     ),
     Val,SortOrder.Ascending) 
     ).Var
     ),
     Value
     ))
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Iantaylor2050 

     

    Concatenate("RAS",Text(First(Sort(yourlist,ID,Descending)).ID+1,"000"))

     

    Would be a bit simpler.  You could add another 0 to "000" if you needed more digits.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Drrickryp 

    It seems that the code generates new serial number randomly, and also adding more digits....

     

    Code: Concatenate("IN";Text(First(Sort(Internordre;ProdNo;SortOrder.Ascending)).'ProdNo (Title)'+1;"00000000"))

    Pic 1 : Shows a existing row in Sharepoint list (created the right way)

    Pic 2: Next generated serial number (Sholud be IN00000002)

     

    Engalpengal2009_0-1708519159429.png 

    Engalpengal2009_1-1708519188822.png

     

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    That's not random, it's the product number from screenshot 1, +1

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    😅Oh my.... I referenced to the wrong column in my code.

    How embarrassing

    @TheRobRush Good thing someone here is awake

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ok. So i have the serial number generator going.
    But when i pach the collection with serial number, it would not "paste" it to a text column (Marked as red).
    I tried like this:

     

    ForAll(Col_Int_Ord,
        Patch(Internordre,
            Defaults(Internordre),
                {
                OrdNo:Text(IOrdNo.Value),
                'ProdNo (Title)':IProdNo,
                TrInf3:ITrInf3,
                Descr:IDescr,
                NoInvoAb:INoInvoAb,
                BestAv:IBestAv
                }
           
        )
    )
     
    The Column needs to be a text column.
    So Is there possible to Generate a serialnuber in a text field?
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Engalpengal2009_0-1708689856425.png

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Try replacing that concatenate bit with this

     

    Text(First(Sort(Internordre,OrdNo, SortOrder.Ascending)).OrdNo+1, "INT00000000")

     

    (though note, if it is supposed to be one higher than most recent  (largest) OrdNo, should it not be

     

    Text(First(Sort(Internordre,OrdNo, SortOrder.Descending)).OrdNo+1, "INT00000000")

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It works fine when the source list is empty, but as soon it has data i get an error.

     

    Engalpengal2009_2-1708936265626.png

    Engalpengal2009_3-1708936282163.png

    The column is ta single line of text, and it needs to be.

    Is there a way to "walk around" this issue?

     

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 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard