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

AutoNumber

(0) ShareShare
ReportReport
Posted on by 31

Hi, I am quite new to PowerApps and have eventally got the majority of my form working, my form is created through MySql which seems to be causing me some issues.

However I have been asked to implement an autonumber function within my app, Is there anyway of being able to sent up a standard autonumber (e.g. 1,2,3,4,5 etc) for each new form?

It would be prefereable if I could even assign these in the backend mysql table and the user never seen these.

Any help would be greatly appreciated.

Thanks

Paula

Categories:
I have the same question (0)
  • SJ-15052312-0 Profile Picture
    418 on at

    Is your question how to implement a column in a table that is an auto incremented integer?  You should create that in sql backend.  The sql server syntax would be:

    [columnName] [int] IDENTITY (1000, 1) NOT NULL

    This starts the number at 1000 and goes up by 1 for each new record.  

    MySQL syntax is:

    ColumnName INT NOT NULL AUTO_INCREMENT

    This starts at 1.

     

    If this is not what you are asking, please clarify.  

     

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Paula,

    What @samuelJ has suggested is preferred. Powerapps does not have a built in auto-increment function. However, you can manually set up an ID column within Powerapps using First(Sort(datasource, ID, Descending)).ID+1 as the default value for the ID of a new record. It’s a good idea to hide it or make it read only so users can’t edit it.  First(Sort Descending is preferable because Last() and Max() are not delegatable, and if the datasource exceeds 2000k records they won’t work.  First(Sort Descending will work even if the number of records is in the millions. Also, make sure your column type is a whole number. 

  • Paula Profile Picture
    31 on at

    @samuelJ @Drrickryp thank you for your help, I already had the backend mysql setup but I wasnt able to get the information to save from the frontend, I have now got the information storing into the database with an auto number linked.  Thanks again

  • Community Power Platform Member Profile Picture
    on at

    Hi Paula, other option would be have a table with a field of control that increments with each patch(), and query only this value.

  • Community Power Platform Member Profile Picture
    on at

    Hi Drrickryp,

    I'm First(Sort(Table1, ID, Descending)).ID+1 as suggested here but the result is that it is stuck when it reaches 10. Please see attachment.

    Thanks,


  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Make sure the column is formatted as number.

     

  • Community Power Platform Member Profile Picture
    on at

    Hi Drrickryp,

    Thanks for your immediate response. I appreciate it a lot.
    I din't know my is just that simple. You save my day.

    Thanks a lot sir.

    But do you have an why that is happening?
    I need more enlightenment.

    Thanks again sir.

  • sludgeza Profile Picture
    27 on at

    Paula how did you do this?

  • Paula Profile Picture
    31 on at

    I set up the mysql table as a autonumber and as int(200)

     

    On Default the card itself I set the default as - 

    First(Sort('databaseandtable',AutoNumber, Descending)).AutoNumber+1

     

    On Default the card itself I set the Update as -  

    Value(textboxvalueisgoingtobein.Text)

     

    This seemed to work for me an increment by 1 each time

  • sludgeza Profile Picture
    27 on at

    Hi,

    So the issue I have is that I am trying to insert a new record on a DB2 database. PowerApps is complaining that it cannot update the record ID field wich I suspect is an auto generate field. I tried your method without sucses. 

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard