Serial number in glide tables

Hi
How to create a serial number for each row in glide tables?

You mean like an auto-incrementing number?
There are a few different ways to approach this - can you describe your use case?

If you just need a random unique key for each row, then you should use a RowID column.

1 Like

Yes, I want auto-incrementing number

for example:
Ticket #1, Ticket #2

Every new row is a new ticket

Okay, here is one way to do that:

One note of caution though: the above technique is subject to a concurrency issue, whereby if you have two or more users adding a record at the same time, then there is a possibility that you could end up with two records having the same ID. So it’s only really suitable if new records are added infrequently.

For high volume usage, the only way that I am aware of to do this and guarantee uniqueness is to delegate the ID assignment to a 3rd party. Either something like Apps Script or an integration tool such as Integromat.

1 Like

I think this process is rather complicated, is there an easier way than this?

There are other options that involve Glide computed columns or Spreadsheet formulas, but I wouldn’t consider any of them simpler than this approach. It’s not something that Glide provides natively, so a little creativity is required.

1 Like

I found a much easier way, By adding only 4 columns
I hope everyone can benefit from it.

1 Like

Just be careful with that method, because if two people submit the form at the same time, you will definitely get duplicate ticket numbers because the math happens on each user’s device. So each user will only see 6 tickets, and if they both submit at the same time, the math on both devices will increment the number to 7, so both submissions will have a ticket number of 7. Be sure to test with multiple devices at the same time.

Also, I would not have used an On Submit action. You should already have your next available number that you can include in the form as a Column Value component. So instead of an On Submit action, you add a Column Value component which passes the value through the form automatically upon submit.

3 Likes

Just adding to what Jeff said (which is all 100% correct)…

  • Your “mo” column is redundant. You could simply just use +1 in your math formula.
  • Because the next ticket number is based on the current number of rows, if you ever delete any rows then things will get messed up. So that’s another thing to be careful of.

Have a read through the below thread for more discussion on this topic, and a couple more possible solutions.

Like I said, there are a number of different ways to approach this, and several different potential solutions. None of them is perfect, and there is no one size fits all. It just depends on the specific use case.

2 Likes

Yes, it is enough to create only two columns

لقطة الشاشة 2021-12-20 090956
لقطة الشاشة 2021-12-20 091654