May 21, 2020 08:16 AM
Is there a sequential order when a new record is created through a Form view? Can you define/control the order?
Solved! Go to Solution.
May 21, 2020 09:57 AM
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?
May 21, 2020 08:29 AM
Welcome to the community, @Paul_Dezzutto!
Yes, there is an autonumber field type that you can choose.
May 21, 2020 08:54 AM
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?
May 21, 2020 09:30 AM
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?
May 21, 2020 09:57 AM
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?
May 21, 2020 10:54 AM
Yep, exactly. Works like a charm even with the form submissions.
Thanks @Jeremy_Oglesby
May 22, 2020 10:00 AM
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
May 22, 2020 10:15 AM
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',
{Leading Zeros} -
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.
May 22, 2020 11:27 AM
The latest version: ‘EV-’&REPT(‘0’,5-LEN({Autonumber}&’’))&{Autonumber}. The leading zeros will always be 5 digits.
May 22, 2020 11:28 AM
But I can see the application where the number of digits would increase or decrease.