Hello AppSheet Community: I am trying to crea...

(SmartD) #1

Hello AppSheet Community: I am trying to create a field that generates a code composed of a serial number, followed by a correlative number. For example: 002-00001, then 002-00002, etc.

For another group of users (who are located in another project) the series changes, for example: 003-00001, then 003-00002, etc. The idea is that it be generated automatically. Is there any way to do it with AppSheet?

(Steven Coile) #2

Certainly possible, though may be a problem if you want them to be unique (see below).

To generate them automatically, you’d have to have some way to determine what the appropriate serial number is, and a means to determine what the highest used correlative number is. Generating a new code given that is trivial.

It might be easiest to handle it as a Text column.

Keep in mind, though, that the app uses a local copy of your data; the central copy is updated when a sync occurs. Sequential identifiers are problematic because multiple users could all start with the same data, each generate the same next sequential value independently thinking they’re the first to claim it, and sync at different times. In such a case, earlier data will be overwritten by later data with the same identifier.

(Aleksi Alkio) #3

You can also read more about it from this article…

help.appsheet.com - Sequential Keys Sequential Keys help.appsheet.com

(SmartD) #4

Hi Aleksi, I understand the problems of working with a correlative key, but this case is not a key, it is a field that the application can generate automatically and correlatively, which does not allow the user to edit. In addition, in this case, being a single user for each project (understand number series: 002, 003, etc) there would be no danger of duplication.

(SmartD) #5

@Steven_Coile

Thanks for your answer Steven.

(Aleksi Alkio) #6

Well… the problem is the same if it’s a key column or not if you have more users than one and you want an unique value. When you have only one user per project and if you can take care that other users are not able to add another project, then you don’t have that problem.

(SmartD) #7

@Aleksi_Alkio So, how to make the application generate correlative numbers? Can you help me?

(Mary Jane Pender) #8

Soporte,

as long as you are not going to have multiple users and you use the Appsheet _Unique key creator for all your tables, then you can also create a more human readable record key by concatenating Some value like your example of “2000”,"-",“0000”,[_RowNumber].

Row number can be problematic if you delete rows, so I always recommend that you remove the table option for Delete.

Sometimes using Today() date as part of a readable “key” is helpful. Hope this helps.

(Aleksi Alkio) #9

Are you able to add a user identifier to your code? For example… if you have less than 100 users, you could assign 01 to you, 02 to Mary etc. Then you could use a code like 002-020001 and they will be unique.