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 / Using Last Item's ID +...
Power Apps
Unanswered

Using Last Item's ID + 1 on New Form to create a Unique ID

(0) ShareShare
ReportReport
Posted on by 71

Hello Everybody,

 

I am creating a SharePoint list customized form on PowerApps. I am trying to concatenate a unique ID using the previous item ID + 1. The idea is to initiate the first item on the list with 1, and have the next item automatically assigned with the number 2 while been concatenated on the Unique ID. Users will not be able to edit the ID# on the form. 

 

Please see below formula I am currently working with to concatenate the Unique ID. 

This formula is placed on the Default property of the Unique ID input datacard.

 

 Concatenate(
 "E",
 Sheet_Size_Drop_Down.Selected.Value, 
 Switch(Texas_District_DropDown.Selected.Value,
 "SETX", "1", 
 "NTX", "2", 
 "SETX - Lufkin", "2", 
 "SETX - Beaumont", "2", 
 "SETX - Huntsville","2", 
 "SETX - Orange", "2", 
 "SETX - Vidor", "2",
 "STX", "3",
 "HOU NW", "4",
 "HOU-SE", "4",
 "LA", "4",
 "MS", "4",
 "TXC", "5"),
 "-",
 (This is were I will need the Previous Item ID number + 1), 
 "-",
 Request_Type_Drop_Down.Selected.Value 
 )

 

Note:

I understand I will might need to use whatever function is giving me the last Item ID +1 in the Submit button since if we concatenate this on the Unique ID earlier, there will be issues if multiple people work on new forms at the same time.

Any help With this would really be appreciated.

 

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    In your form put something like below (it would handle up to 100 simultaneous submissions from different users, anything over that you would need to expand the search) into the OnSuccess of your form

     

    ClearCollect(recordFinder,
    ForAll(
     Sequence(100,1,1),
     ////CHANGE EditForm1 to your Form Name
     If(First(LastN(CalendarDates,ThisRecord.Value)).ID=EditForm1.LastSubmit.ID,
     {ID:First(LastN(CalendarDates,ThisRecord.Value+1)).ID}))
     
     ); 
    
    Set(recordVar,First(recordFinder).ID);
    
    UpdateIf(SourceList, ID=EditForm1.LastSubmit.ID, {UniqueIDColumn: (place your concatenate here, with recordVar added to it as it is the value of previous submitted items ID) })
  • 00236123 Profile Picture
    71 on at

    Hello, 

    I have tried using your formula on my Form's OnSuccess  but I'm not sure if I need to change anything else. PowerApps is showing almost everything as an error on the formula. Please let me know if I still need to change anything on the below formula. Thanks for your help. @TheRobRush 

    ClearCollect(recordFinder,
    ForAll(
     Sequence(100,1,1),
     If(First(LastN(CalendarDates,ThisRecord.Value)).ID=SharePointForm1.LastSubmit.ID,
     {ID:First(LastN(CalendarDates,ThisRecord.Value+1)).ID}))
     
     ); 
    
    Set(recordVar,First(recordFinder).ID);
    
    UpdateIf('CNP Drafting Request - PowerApps', ID=SharePointForm1.LastSubmit.ID, {: 
    //(place your concatenate here, with recordVar added to it as it is the value of previous submitted items ID) 
     Concatenate(
     "E",
     Sheet_Size_Drop_Down.Selected.Value, 
     Switch(Texas_District_DropDown.Selected.Value,
     "SETX", "1", 
     "NTX", "2", 
     "SETX - Lufkin", "2", 
     "SETX - Beaumont", "2", 
     "SETX - Huntsville","2", 
     "SETX - Orange", "2", 
     "SETX - Vidor", "2",
     "STX", "3",
     "HOU NW", "4",
     "HOU-SE", "4",
     "LA", "4",
     "MS", "4",
     "TXC", "5"),
     "-",
     recordVar, 
     "-",
     Request_Type_Drop_Down.Selected.Value 
     )
    })

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @00236123 

    When you are incrementing a number field using Last() or Max() you will be limited by delegation to a maximum of 2k items.  Instead, use First(Sort(table, uniqueID, Descending)).uniqueID+1 to get the next number.  Although First() is also delegation limited, Sort() isn't and so it will sort any number of items and getting the first one will not be a problem. 

  • TheRobRush Profile Picture
    11,128 Moderator on at
    ClearCollect(recordFinder,
    ForAll(
     Sequence(100,1,1),
     If(First(LastN('CNP Drafting Request - PowerApps',ThisRecord.Value)).ID=SharePointForm1.LastSubmit.ID,
     {ID:First(LastN('CNP Drafting Request - PowerApps',ThisRecord.Value+1)).ID}))
     
     ); 
    
    Set(recordVar,First(recordFinder).ID);
    
    UpdateIf('CNP Drafting Request - PowerApps', ID=SharePointForm1.LastSubmit.ID, {: 
    //(place your concatenate here, with recordVar added to it as it is the value of previous submitted items ID) 
     Concatenate(
     "E",
     Sheet_Size_Drop_Down.Selected.Value, 
     Switch(Texas_District_DropDown.Selected.Value,
     "SETX", "1", 
     "NTX", "2", 
     "SETX - Lufkin", "2", 
     "SETX - Beaumont", "2", 
     "SETX - Huntsville","2", 
     "SETX - Orange", "2", 
     "SETX - Vidor", "2",
     "STX", "3",
     "HOU NW", "4",
     "HOU-SE", "4",
     "LA", "4",
     "MS", "4",
     "TXC", "5"),
     "-",
     recordVar, 
     "-",
     Request_Type_Drop_Down.Selected.Value 
     )
    })

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

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard