How do I create an auto-incrementing row number with Glide Tables?

This is a question that comes up a lot, so creating this topic to use as a reference.

Typically, there are two distinct use cases when it comes to auto-incrementing row numbers.

  • Use Case 1:
    – We need to generate a Part Number, or an Order Number, or an Employee ID. Once the number is generated, it should never change, even if rows are deleted.
    – The general approach for this use case is to maintain a static counter, use it to craft a suitably formatted ID, and increment it by one every time a new row is added.
    – The following video walks through that step by step:

If the above video won’t play, paste the following into a browser:

https://www.loom.com/share/58bb8a0bc8294fd9b03ca68467e924ed?sid=2e96e0b1-d1ff-42f0-bfd2-dd4926af953d
  • Use Case 2:
    – For the second use case, we want a dynamic row number that will automatically change as new rows are added/removed.
    – The solution for this use case is very simple, and takes advantage of one of the new Array Plugin columns. Credit to @11183 for first describing the approach.
    – The following video shows how to do it:

If the above video won’t play, paste the following into a browser:

https://www.loom.com/share/13166419c13d4e44b961d01be5f2f801?sid=5f479f3d-92e9-4397-92cc-0df0b34f2cd4

32 Likes

Hi @Darren_Murphy , thanks for this F.A.Q.
About case 1, I use the same method but with a little variation:

  • instead of building the two template columns (one in staff, and one in lookup), in lookup I prefer to define a rowid column, retrieve its content in staff via a single value column, and then build a single relation between these two values.
    Could it be better from a performance standpoint, in your opinion?
1 Like

hey @Roldy

I’m not sure I could say whether one approach is better than the other. The end result is the same in both cases, because you need that single relation. It’s just a matter of how you get there. My guess would be that it probably doesn’t make much difference for this use case. I think your approach is fine :slight_smile:

2 Likes

Great explanations @Darren_Murphy ! Bookmarking these for future use!

Nice. Changing the category to “Tutorials” instead of Help.

Thanks for this! Will get referenced a lot, I’m sure.

1 Like

Used this method for an app that multiple user get access

But the number always get off, for example:

90
91
92
(blank)
23
54
55

the number doesnt consistently follow from the number we used to start the number

1 Like

Can you share details of how you implemented this?

If I was to make a wild guess, I’d say it sounds like you might be using some User Specific Columns where you shouldn’t be. But that is just… a wild guess

created another table (Table B)
in Table B

then at the original table
i create a relation to table B (Number) and call a single value out of it
relation from table A

So whenever a user create/add a entry, i call the single value , and auto increment the table B’s Number by 1

It looks like you have some sort of variation of the first option that I showed in my original post.

Is there any reason why you didn’t want to set it up in a similar way that’s shown in the video?

hmm, im sorry arent it the same ?
since i call a relation to the lookup value ?

or is it important to check the current user ?

btw, im still abit confused about the If Then Else function there ?
what does it do ?

In the example I showed in the video, the if-then-else column is used to determine if the EmployeeID needs to be zero-padded. You can probably ignore that.

No, it doesn’t look the same to me.

Using the signed in user ID is used in a template to create a relation between the two tables.
Actually, looking back at that now, it could be simplified quite a bit. Instead of using templates to create a relation, we could just use a Single Value → First → Whole Row to grab the whole first row from the Lookup table, and then use a Lookup through that Single Value to fetch the next ID, and also use it for the onSubmit increment action.

Make yourself a copy of the below App and use that as an example for your own - you might find it a bit simpler to understand.

Ok Thanks for the explanation and the copy of the apps
cause since the beginning creating my own apps, im been stuck to that auto increment, already watch the video multiple time, but still dont get it. :melting_face:

hope this method wont show any blank or random number again

anyway can i ask about the number entry? im sorry if its not about this topic

while inputting a price number, is it possible to have a realtime comma separating thousand automatically ?

No, but if you format the column where the Number is being saved to include a group separator, then it will be inserted when the saved value is displayed.

Note: the separator used can vary, according to the Users device regional settings. ie. some regions use a period (.) instead of a comma

2 Likes

hello, did that method, but it still make error

Capture

input by multiple user with row owner set up

Obviously, something is wrong. But it’s really difficult for me to say what just by looking at a single screen shot. If you set it up the same as in the concept App, it will work, even with Row Owners applied. So if it’s not working for you, that means you must have done something different. In order to help you solve it, you need to help me understand what it is that you’ve done different.

2 Likes

Ola boa noite… nao estou consegiundo realizar este modelo como no video, sera que poderia me ajudar… ele gera o codigo porem inseri um monte de zero no final…

If you show me how you have set it up, I may be able to point out where the problem is.

BOM DIA TUDO BEM, SEGUE PRINTS DE COMO EU CONFIGUREI… SERA QUE SE EU TE DER ACESSO AO SISTEMA VC PODERIA VERIFICAR PARA MIM POR GENTILEZA?