cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Salehkhalil
Frequent Visitor

How I can show the ID number when create items

93D72313-98ED-4B7C-A936-0452EA97DD77.jpeg

how I can show the ID number from database (share point) in power app screen, as showing in attachment all time give me error 

2 ACCEPTED SOLUTIONS

Accepted Solutions

So I can show the previous ID then +1,

or is there any way?

View solution in original post

@Salehkhalil 

Something along the lines of this will give you the highest ID+1

First(
   SortByColumns(YourDataSource, "YourIDField", Descending)
).YourIDField + 1

 

View solution in original post

6 REPLIES 6
Pstork1
Dual Super User
Dual Super User

Unfortunately, the ID isn't assigned by the system until after a new item is submitted.  So you can't show it on creation of a new item.  You can show it when editing an existing item.



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

So I can show the previous ID then +1,

or is there any way?

You should be able to show the previous highest ID +1.  But that won't be guaranteed to be the right ID.  There are a couple cases where it would show the wrong value.

  • A previous entry was created and then deleted.  Deleted IDs won't be reused so the highest ID currently +1 will be one short.
  • If two people create items at the same time they might both show the same value for highest ID +1, but the resulting items will have different IDs. Only one would be correct.


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

Could you support me for writing the code to show the highest ID+1

@Salehkhalil 

Something along the lines of this will give you the highest ID+1

First(
   SortByColumns(YourDataSource, "YourIDField", Descending)
).YourIDField + 1

 

Pstork1
Dual Super User
Dual Super User

@timl 's code should do it.  But remember that is based on the current highest ID and may or may not represent the next ID to be assigned.



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

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,943)