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 create an uniqu...
Power Apps
Unanswered

How to create an unique ID ? (Data source: SharePoint List)

(0) ShareShare
ReportReport
Posted on by 19

Hello,

 

I need to create unique IDs in Power apps in this format "Year-<incremental number>" for each request created in my form. The data source of my form is a SharePoint list. I want this ID to appear in the SharePoint List and also, when viewing the request that was submitted in this Power Apps form.

 

I'm using this formula in default property, and it's working. BUT when I click in the "view" mode, the ID gets different (increases 1 number)

 

That's the formula used: 

Concatenate(Year(Today()), "-", Text(CountRows(Filter('SharePoint List', Year(Created)=Year(Today())))+1))

 

For example, If I create one request in my form, the ID is 2023-1. If I check this created request in "view" mode, I see it as "2023-2".

 

How can I fix it?

 

Thank you very much.

 

Categories:
  • mmollet Profile Picture
    3,187 on at

    Sharepoint had a unique column for every item in ID as well. This is what I always use for this type of thing.

     

    Year(Now()) & "-" & Text(ItemsIDHere,"0000#")

     

    Not sure if this is an option for you or not.

  • julia123 Profile Picture
    19 on at

    Hi, 

     

    What should I add in ItemsIDHere? I want that Power apps create the IDs automatically.

     

    Ex: 2023- 1

    2023-2

    2023-3

     

    And so on 🙂

     

    Thanks,

     

  • mmollet Profile Picture
    3,187 on at

    You would add the items ID from sharepoint. Depending on where you are at and what you are doing the way to get this ID may be different. 

     

    Does the item already exist in SP or are you creating it as a new row as you do this?

  • julia123 Profile Picture
    19 on at

    It's a app where you submit a request in a Power Apps form. 

     

    Once you have submitted it, there's a page in the app where you can view your request (so, in view mode).

     

    For each and every request created, I need to add a different ID, an identifier. And it should look like this: "2023-1" for the first request creates. "2023-2" for the second one, etc.

     

    With this formula, in default property, I was able to make it happen:

    Concatenate(Year(Today()), "-", Text(CountRows(Filter('SharePoint List', Year(Created)=Year(Today())))+1))

     

    My problem is that, when checking the created request, in View mode, the ID appears differently. 

     

    So, if I create the first request, I can see when creating it, that's the "2023-1". But, after saving/submitting it, in View mode, I see the ID as "2023-2", and not "2023-1". "2023-1" should be the correct, as this was the first request I`ve created.

     

    Please, let me know if I was not clear, and thank you very much for your replies !!

     

     

  • mmollet Profile Picture
    3,187 on at

    So I generally use Patch statements instead of forms but I will explain what I would do and maybe you can translate it into your solution and make it work there as well. Generally I use a formula like:

    ClearCollect(lastPatchedItem, Patch(SPListName, Defaults(SPListName)))

     

    What this does is it created a blank item with all the defaults in the columns (if there are any) and then saves that row to a collection called lastPatchedItem. Then I can execute another patch statment directly after it but this time I have the row already created so I just want to edit it. Good thing I have the ID of the row I want to edit in SP stored in the item in the collection I made. The code for this would look something like: 

    Patch(SPListName, ID = First(lastPatchedItem).ID, {FirstName: textinput1.text, LastName: textinput2.text, uniqueID: Year(Now() & "-" & Text(First(lastPatchedItem).ID,"0000#"})

     

    What this does is it finds the row we just made in the first patch statement, sends the actual data we want to store (similar to what your form is doing) but this time it has access to the unique ID and you can format it to be whatever you want at that point. In this case say it is SP ID 28. The value in uniqueID column for that new row would be:

    2023-00028

     

    Again I hope this helps. I have used forms as a quick setup then just used patch statement like listed above to send to SP rather than using submit form but this depends on how complex your data is in SP. I keep all my data to strings, integers/floats, or dates to avoid having comples data that is hard to patch.

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