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 / how to use regex on te...
Power Apps
Answered

how to use regex on textfield in powerapp to generate a unique ID

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, I am working on powerapp. I want to generate a unique ID upon clicking on sending order button. I am trying to explore using regex but I have no idea how to implement the code. Can someone teach me how to use regex (regular expression) in powerapp to generate a unique ID?

 

my current code for ID

aaaa3_0-1673232759897.png

 

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    You might consider using the GUID function to generate unique IDs efficiently.

     

    Text(GUID())

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-xiaochen-msft 

    I tried using GUID function but it doesnt work.

    I want to create an unique ID with prefix "ABC_" so the sharepoint list data will have ABC_1432 as an example.

    May I know how to do so?

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Please try:

     

    With(
       {OrderID:First(Sort(OrderList,OrderID,Descending)).Value},
       "ABC_"&Text(Value(Last(Split(OrderID,"_")).Result)+1,"0000")
    )

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-xiaochen-msft 

     

    I have modified the code abit.

    aaaa3_0-1673251722928.png

    The error I received after clicking on submit button is The value 'PSA_329378073' cannot be converted to number.

     

    Submit button

    aaaa3_1-1673251812301.png

    May I know how to resolve this? thank you

     

    aaaa3_2-1673251899677.png

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    The point is that the string "PSA_329378073" can not be converted to number...

    It's by design.

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-xiaochen-msft 

    Okay I understand. May I know if there is any way for me to auto generate an ID that contain "PSA_329378073" in powerapps. I need use as reference ID.

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Please replace

     

    Value(OrderID)

     

    with

     

    With(
       {TheOrderID:First(Sort(OrderList,OrderID,Descending)).Value},
       "PSA_"&Text(Value(Last(Split(TheOrderID,"_")).Result)+1,"00")
    )

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hii, if I replace Value(OrderID) with the following you mentioned, I will have error.

    may I know if is it possible to store lbl_Orderid into a variable then use OrderID = newvar  in my submit button

     

    aaaa3_0-1673256912452.png

     

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard