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 / Autogenerate a number
Power Apps
Answered

Autogenerate a number

(0) ShareShare
ReportReport
Posted on by 103

Regards

 

I need to generate a sequential number however this number must be concatenated by a prefix according to the type of law choose by a dropdown by the user and the sequences are individual for each region. For example: OPM2018-001 because the type is OPM but I can have in another region/office that same number because its sequences are individual for each region. I use office365User.Myprofile().OfficeLocation and save it in a global variable.  I have a Type table.  

 

Any ideas will be appreciate.

 

veronica

Categories:
  • Verified answer
    v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Veronica,

     

    What do you mean by "Type" table? From your formula I understand that you have an Office365 Users connection in this app, but is this Type table another data source? If so, please tell what is this connector. 

     

    My understanding so far is that you need the number to be like:

    Dropdown1.Selected.Value+"-00X"

     

    If so, then you just need to follow below steps:

    1. Set below formula in the OnVisible property of the screen:

     

    Set(Test1,"001");Set(Test2,"001");Set(Test3,"001")

     

     

    2. Set below formula in the OnSelect property of a button control:

     

    If(Dropdown1.Selected.Value="OPM",UpdateContext({Test1:Test1+1},Dropdown1.Selected.Value="XX",UpdateContext({Test2:Test2+1},Dropdown1.Selected.Value="XXX",UpdateContext({Test3:Test3+1}))

     

     

    3. Set below formula on the Text field of the label control that you want to show the required number:

     

    If(Dropdown1.Selected.Value="OPM",Concatenate("OPM",Test1),Dropdown1.Selected.Value="XX",Concatenate("XX",Test2),Dropdown1.Selected.Value="XXX",Concatenate("XXX",Test3))

     

    Regards,

    Mona

  • Tom_Slosse Profile Picture
    1,430 on at

    Hey @Veronica

     

     

    You could put that logic in a Flow and then send it back to your app.

    In Flow you can do more things like generating a number with a prefix and so on.

    You could set some variables and then with compose or other data operations you could do your magic.

     

    Hope this helps

     

    Kind regards

     

     

    Tom

  • Veronica Profile Picture
    103 on at

    Hi,

     

    Thank you very much for your recomendation and your time.  I work in Courts.  Type table is a support table that has the type of law or issue the user is going to record on my app.  Like a wedding, Law125, Law246, etc .  The autogenerate number should be a combination of the prefix of the law-year-number for example (OPM-2018-025).  Its like a case number, but the complication is that each court  has their own sequence.  The table that has all the records with all the information is call Detail table. So I dont know what function to use in order to go to Detail table, evaluate the court of the user, look in Detail table the last number for that court(user's court) and increment +1. 

     

    Vero 

  • Veronica Profile Picture
    103 on at

    Thank you for your time, Tom.  I am trying not to use Flow because my MS partner told me that I have a limitation in Flow license.  Also, I don't know much only the basic basic of Flow.  

     

    Thanks,

     

    Veronica

  • Veronica Profile Picture
    103 on at
    Finally I did it. Thanks all for your help. veronica
  • Verified answer
    Veronica Profile Picture
    103 on at
    I used a Carlos Figueira blog in Generate Inventory Number and change it a little bit, I need it to use the right function intead of the mid function he use. This is only part of the solution. Then I had to Concatenate with other part of the final number. Then I used Mona's 3 step. Text( Value( Right( First( Sort( Filter('[dbo].[Detalle]',StartsWith(vOfficeLocation,Oficina)&&(vTipo=Valortipo)),vNumeroPeticion,Descending).vNumeroPeticion).vNumeroPeticion,3)+1,""))

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard