Auto Numbering

Actually, yes and no.
My use case for this is that I have a sheet with several logical groupings of rows.
And for each group, I want an auto-incrementing column from 1-n
So I’ve inserted the above formula pattern in the first row of each group, and it works, but…

If I insert a column into any of the groups, then the number sequence in all groups below it is immediately offset by one… so instead of starting at 1, they start at 2. In typing this out, I’ve realised that this happens because the return value of row() changes, but I can’t think of a way to get around it - can you?

Something like this I guess?

Darren: I have been able to implement every solution you have ever posted, but am stumped here. Feels like circular logic of some kind. If I manually enter the first row with an Order ID of 1001, the max rollup will be 1001. The New Order ID will be 1002 for the second row. But when the third row is created, max rollup is still reading Order ID of 1001 and makes New Order ID 1002 again. Where I am off track here? Thank you

Sounds like an issue with your rollup that gets the max ID.
Can you show me screenshots of:

  • The GDE showing the relevant column names
  • The configuration of the rollup column


That looks okay.

So when you add a new row, you should be taking the value of the signalID2 column, and using that as the signalID for your new row.

Is that what you are doing?

I am, but the value of signalID does not change, so the Max is always the same.

It wont change automatically with this method, you have to set it when you add a new row.
That’s the purpose of the rollup and math columns - to determine the value to use when the next row is added.

OK, I tried to auto increment signalID upon form submit, but it did not work. Trying make this work in Glide pursuant to your suggestion in this thread. I will stay at it. Thanks Daren

No, that’s not the way to do it.

hmm, are you using a native form (show form screen) or a custom form?

I mostly only use custom forms, so I’d have to think about how you’d set this when using the native form.
I guess what you’d need to do is add a Screen Column (in the form screen) that has signalID as the target, and signalID2 as the source. Then when the form is submitted, signalID should automatically be set as the current value of signalID2 in the newly added row.

Native form. Further complicated since I am going to the form from a inlist list of “signal providers,” so screen columns refer to the signal provider table, not the signal table. Flow is the following: user selects signal provider, then adds a signal that is linked to that provider. I can get the signal provider ID into the signal record, but want to auto-increment a signal ID with each record. (One signal provider will have hundreds of records in the signal table.)

How about if you add a single value column to your Signal Providers table, that takes the first value of signalID2 from your Signals table?

You should then be able to use this column as a screen column in your form.

One thing to be aware of with this method is that it is subject to race conditions. That is, if you have two or more users adding records at the same time, then there is a possibility you could wind up with duplicate SignalID’s.

So just keep that in mind.

2 Likes

Will give it a try. Thank you

Success. You keep your perfect record Darren.

Thank you

1 Like

Hi I’m trying to generate a 4 digit User ID which serves as referral code. Still struggling despite this long topic… the solution looks very smart but doesn’t work, getting same issues as @gp9293 - do you mind sharing a gif or video with the complete set up ?

You’re in luck, I made one earlier today.
Not exactly the same method, but essentially the same end result…

Thanks but the incremented ID needs to be generated upon a new user sign in to the app (I don’t want them to submit a form in addition…) so the actions tool won’t help, I tried all possible tweaks in mentioned in this topic.

oh, that’s a completely different animal.
If you can’t use an action, then I assume you have no onboarding process?
Is it out of the question to intervene the first time a user signs in and get them to tap a button?
If yes, then the only thing I can think of - IF you are using a Google Spreadsheet - would be to set a trigger to watch the App: Logins sheet, and do something each time a new user is detected (it would need to check to only act on new logins, and ignore existing users logging in).

3 Likes

Hi, Darren, and thanks for a great explanation!
Can you explain or better show how you transfer the value of the NEXT ID cell to the actual ID column?
As I understand, there should be the initial point/cell where counting starts, then there are three more additional columns to increase the highest number by one and add zeros. And then the value of the next ID has to be copied and not referenced, by creating a new row, to the ID column’s last cell.
How to copy and not refer?

Yes, that’s correct.
From my example, the current value of the last column (“Next OrderID”) would be used in an Add Row action to set the OrderID for the new row being added.

This was quite a while ago, and there are other ways to do this, but which is best depends on your specific use case. For an alternative option, please check the video in the below post: