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 Apps
Answered

Generate Unique ID

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Dear, 

I am building an application to collect some information at the office, I am trying to generate a unique ID based on SharePoint List ID (called raID, auto increment, primary key).

The formula I used OnSelect event is: 

UpdateContext({NewID:If(RapidAssessmentEditForm.Mode=FormMode.New, "BSA-00"& Last(listRapidAssessment).raID+1,NewID)});SubmitForm(RapidAssessmentEditForm) 

 

Than assigned the NewID to Default value of a text box at the form RapidAssessmentEditForm: 

If(RapidAssessmentEditForm.Mode=FormMode.New,NewID,Parent.Default)

 

If I used the application by one person, it works well but at the time we have two users, the NewID start duplicate.

Thanks for you support in advance! 

Best Regards

Mahmoud 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @Anonymous ,

    On the Save code

    If(
     RapidAssessmentEditForm.Mode=FormMode.New,
     UpdateContext({vNew:true}) 
    );
    SubmitForm(RapidAssessmentEditForm)

    Now on the OnSuccess of the Form

    If(
     vNew,
     UpdateContext(
     {
     vNewID:"BSA-00"& Self.LastSubmit.raID,
     vNew:false
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @WarrenBelz 

    Thanks for your support, but how to save the value to SharePoint list? I added vNewID as a Default value to code text box, but it did not save the value (as it is generating the vNewID value at OnSuccess, which mean the data submitted to the list.)

    If(RapidAssessmentEditForm.Mode=FormMode.New,vNewID,Parent.Default), I tried to remove this statement too, but it dose not save the vNewID to the list.

     

    Best Regards

    Mahmoud

  • Verified answer
    WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @Anonymous ,

    Are you trying to save the ID of the new item back to the same item in another field?

    If(
     RapidAssessmentEditForm.Mode=FormMode.New,
     UpdateContext({vNew:true}) 
    );
    SubmitForm(RapidAssessmentEditForm)

    OnSuccess

    If(
     vNew,
     Patch(
     YourListName,
     {ID:Self.LastSubmit.ID},
     {NewID:"BSA-00"& Self.LastSubmit.raID}
     );
     UpdateContext({vNew:false}
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard