Skip to main content
Community site session details

Community site session details

Session Id : j5inkV0K/5DaNJJeKYKZt5
Power Apps - Building Power Apps
Unanswered

Generate Unique ID on PowerApps

Like (0) ShareShare
ReportReport
Posted on 26 Oct 2022 11:11:01 by 12

I would like to generate Unique ID from Powerapps on every new item creation. Right now I am using the below code but I did not find the way to do it, Any help would be appreciated.

 

I have a dropdown which is "DataCardValue80", I need to have the prefix defined based on dropdown selection software "s- "or Infrastructure "I-" in the textbox with unique ID generation 

 

Ex: 1. S-01

     2. I-02

 

If((DataCardValue80.Selected.Value="Software"),"S-",(DataCardValue80.Selected.Value = "Infrastructure"),"I-" && First(Sort('SPList','No.')).'No.'+ 1)

 

  • nikhilprakash8 Profile Picture
    12 on 27 Oct 2022 at 10:46:41
    Re: Generate Unique ID on PowerApps

    @CNT Navigate('Create New Request') and I have dropdown ("","Software","Infra"), then based the dropdown selection I need to have unique Id in textbox with prefix S- and I-, when dropdown is blank textbox should be blank. 

     

    I have used If((DataCardValue80.Selected.Value="Software"),Right(Text(Rand()*3),2)&"-"&Right(Text(Rand()*3),3),(DataCardValue80.Selected.Value = "Infrastructure"),Right(Text(Rand()*3),2)&"-"&Right(Text(Rand()*3),3))

     

    But still no result. I have save button "SubmitForm(Form4)"

  • CNT Profile Picture
    10,919 Super User 2024 Season 1 on 27 Oct 2022 at 10:41:42
    Re: Generate Unique ID on PowerApps

    @nikhilprakash8 Can you share the code you have for creating a new record.

  • nikhilprakash8 Profile Picture
    12 on 27 Oct 2022 at 05:54:18
    Re: Generate Unique ID on PowerApps

    @CNT It does work but when dropdown is blank it shows 1. As I was thinking to the textbox blank.

     

    Second, On every new record or new item creation it want to have new IDs like First item S-1, second item S-2. But with the above code on every new item creation it shows S-1 or I-1

  • CNT Profile Picture
    10,919 Super User 2024 Season 1 on 26 Oct 2022 at 12:18:52
    Re: Generate Unique ID on PowerApps

    @nikhilprakash8 

    Please try the following,

    With({varNo:First(Sort('SPList','No.')).'No.'},
    	Switch(DataCardValue80.Selected.Value,
    			"Software", "S-",
    			"Infrastructure", "I-"	
    	) & Text(varNo+1)
    )

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete