web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps/SharePoint L...
Power Apps
Unanswered

PowerApps/SharePoint List - Generate automatic ID

(1) ShareShare
ReportReport
Posted on by 29

Hello all. 

 

I have a PowerApp that allows entering inspection data into a SharePoint list (each row is an inspection). 

I want to automatically generate an ID that increments every time a new inspection is created in the format FY24/01, FY24/02,... 

Is there a way to do so without using SharePoint ID? 

I have tried the below formulas but it is linked to the ID and I want to avoid using it as I can't reset it and there will be some gaps.

If(
Form1.Mode = FormMode.New,
Last('Data Source').ID + 1, // Generate an ID value when you add a new record using the app
ThisItem.ID
)

 

I appreciate your help. 

 

Categories:
I have the same question (0)
  • KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at

    Hi @mate,

     

    The code you have looks good. It does ID only atm but would need only small changes to make it create an ID using format FY24/01, FY24/02, etc.

     

    Are you looking for code which creates an ID with this format?


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • mate Profile Picture
    29 on at

    Hello @KeithAtherton

    Yes, I am looking for a different way to generate an ID that is not the SharePoint ID to avoid gaps. Any idea?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @mate 

    First(Sort('Data Source', newID, Descending)).newID+1 would be the formula for automatically calculating the next newID.  Last() and Max() are not delegatable and will create errors once your list exceeds the row maximum in the Settings.  You can add the Month and Year as a prefix as follows:

     

    "FY"&Text(Year(Today()),yy)&Text(Month(Today()),mm)&First(Sort('Data Source', newID, Descending)).newID+1

     

    To automatically set it for a form, you can put it in the Update property of the newID card as 

     

    Coalesce(Parent.Default, 
     "FY"&Text(Year(Today()),yy)&Text(Month(Today()),mm)&First(Sort('Data Source', newID, Descending)).newID+1
    )

     

    and set the Display mode of the card to View or Disabled so the user can't change it.  Coalesce() reads its elements from left to right until it finds a nonblank value. In New forms, Parent.Default is blank so it will use the formula.  In edit forms, Parent.Default will not be blank.  By putting it in the Update property, the user won't be able to edit it and you can hide the card if you wish. You can also put the second formula in the control inside the card so it can be viewed. 

     

  • mate Profile Picture
    29 on at

    Hello @Drrickryp

    Thank you for your help! 

    I believe I am doing something wrong (I am a beginner) and it doesn't work. 

    In the Update property of my Title card (where I want the Ref number) I have used:
    Coalesce(Parent.Default, "FY24/"&First(Sort('FY24 Regulatory Tracker', Title, Descending)).Title+1) 

    But I get the below errors:

    mate_0-1675172129617.png

    What am I doing wrong? 

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @mate ,

     

    Not sure if you ever got this sorted, but it seems there were some double quotes missing in @Drrickryp 's formula:

     

    Coalesce(
    	Parent.Default, 
     "FY"& Text(
    		Year(
    		Today()
    		),
    		"yy"
    	) & Text(
    		Month(
    			Today()
    		),
    		"mm"
    	) & First(
    		Sort(
    			'Data Source', 
    			newID, 
    			Descending
    		)
    	).newID+1
    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard