cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Paula
Helper I
Helper I

AutoNumber

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

1 ACCEPTED SOLUTION

Accepted Solutions

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. 

View solution in original post

17 REPLIES 17
samuelJ
Responsive Resident
Responsive Resident

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.  

 

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. 

View solution in original post

@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

HugoMau
New Member

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

Anonymous
Not applicable

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,


Make sure the column is formatted as number.

 

Anonymous
Not applicable

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.

Paula how did you do this?

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (60,313)