# Using Formula to Create Autonumber

Topic Labels: Formulas
Solved
8745 9
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

Is there a sequential order when a new record is created through a Form view? Can you define/control the order?

1 Solution

Accepted Solutions
14 - Jupiter

@Paul_Dezzutto

I think the answer here is yes, based on what you are saying and the formula you showed us. I’m not sure what your `{Leading Zeros}` field is holding, but I assume it’s just a number representing the total length you want the numeric portion of your ID’s to be.

So if you want the numeric portion of your ID’s to always be 5 digits long…

``````00001
00002
02308
etc...
``````

then you can just replace that reference to `{Leading Zeros}` with the number 5 – your formula will continue to behave the same way.

Is that what you were asking?

9 Replies 9
18 - Pluto

Welcome to the community, @Paul_Dezzutto!

Yes, there is an autonumber field type that you can choose.

5 - Automation Enthusiast

Thanks, I don’t think I phrased the question very well. I’ve set up my primary formula with this: ‘EV-’&REPT(‘0’,{Leading Zeros}-LEN({Autonumber}&’’))&{Autonumber}
When a user submits a new record via a form view, the formula does pick up the 'Leading Zeros value. Can I set a static value for the Leading Zero in the formula?

18 - Pluto

No, unfortunately, Airtable does not support static values (aka “global values” in other programming languages).

What are you trying to do? Just trying to set a certain amount of leading zeroes in your formula?

14 - Jupiter

@Paul_Dezzutto

I think the answer here is yes, based on what you are saying and the formula you showed us. I’m not sure what your `{Leading Zeros}` field is holding, but I assume it’s just a number representing the total length you want the numeric portion of your ID’s to be.

So if you want the numeric portion of your ID’s to always be 5 digits long…

``````00001
00002
02308
etc...
``````

then you can just replace that reference to `{Leading Zeros}` with the number 5 – your formula will continue to behave the same way.

Is that what you were asking?

5 - Automation Enthusiast

Yep, exactly. Works like a charm even with the form submissions.

Thanks @Jeremy_Oglesby

4 - Data Explorer

This would be helpful for something I am doing, but obviously I’m missing something.

How are you creating the Autonumber field? That has to be a string and not a number in order to use the LEN formula, right?

Thanks.

Paul

14 - Jupiter

@Paul_Burchfield

The Autonumber field is just that - an Autonumber field. Its value is an integer produced automatically, sequentially, and which cannot be edited.

In @Paul_Dezzutto’s formula, he is able to use the `LEN()` function on the Autonumber field because he is coercing the integer returned by that field into behaving like a string by concatenating it with an empty string inside the `LEN()` function.

Here’s his formula:

``````'EV-' &
REPT(
'0',
LEN({Autonumber} & '')
) &
{Autonumber}
``````

Notice that inside the `LEN()` function he has `{Autonumber} & ''` – that `& ''` is concatenating an empty string onto the end of the integer returned by `{Autonumber}`, and doing that forces that integer into behaving like a string when it gets evaluated by `LEN()`. So `LEN()` is ultimately getting the length of the value in the `{Autonumber}` field if it were a string.

5 - Automation Enthusiast