Help

Re: Unique Project Number Formula Help

Solved
Jump to Solution
3100 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Austin_Adesso
5 - Automation Enthusiast
5 - Automation Enthusiast

Hey all, we are trying to get unique project numbers for our airtable. (We are managing video projects). Last year, we just did an auto number and had a formula to add 20000 to that number. 20001, 20002, 20003, etc. This year, we want the unique project number to be P21001, P21002, P21003… P for our name, 21 for Year, and 001 for the unique project number. We also want 2020 projects to be P20001, etc.
Screen Shot 2021-01-08 at 9.47.49 AM

I found in the forum the formula for getting the YY: MOD(YEAR(CREATED_TIME()), 100)

Can someone help me figure out how to make the formula that will work for any year in this way?

Thanks so much in advance!!
Austin

1 Solution

Accepted Solutions
Jeremy_Oglesby
14 - Jupiter
14 - Jupiter

Many people have asked about resetting an Autonumber field per some time-interval, and to my knowledge, a solution has not been found that utilizes only Formula Fields. It’s just one of those things that Fields alone can’t handle.

The outcome you are wanting is definitely possible with an Automation using a Script action, though. The basic setup for that would be:

  • A trigger of “New record created”
  • A script action that queries all your project records from a view that filters to show only current year projects, counts how many there are, then creates a project number that is YY & count + 1 and updates the newly created record with that project number

See Solution in Thread

13 Replies 13

Hi @Austin_Adesso and welcome to the community!

Couldn’t you just use the formula DATETIME_FORMAT(CREATED_TIME(),"YY") ?

"P"&DATETIME_FORMAT(CREATED_TIME(),"YY")&ID (where ID = auto number field) should work, but in format “1” in stead off “001”.

Jeremy_Oglesby
14 - Jupiter
14 - Jupiter

Many people have asked about resetting an Autonumber field per some time-interval, and to my knowledge, a solution has not been found that utilizes only Formula Fields. It’s just one of those things that Fields alone can’t handle.

The outcome you are wanting is definitely possible with an Automation using a Script action, though. The basic setup for that would be:

  • A trigger of “New record created”
  • A script action that queries all your project records from a view that filters to show only current year projects, counts how many there are, then creates a project number that is YY & count + 1 and updates the newly created record with that project number

Could conditional formatting be another solution? If YY = 20, then xyz, if YY = 21, then abc?

The problem with that is how to generate “001”, and then “002”, and so on, as the “abc” you allude to. Sure, you can create a formula with that conditional statement, but where are you getting “abc” from? You have “xyz” (ie, “393”), sure, but how are you going to generate a new automatic sequence starting with “001”?

Unless I am mistaken (which happens more often than I’d like), the only way to generate the new numbering sequence for each new year, within Airtable’s system, is via a Script.

It’s not perfect, but you could create a manual rule every year that would subtract the previous years total from the automatic number generated for this years projects.

Ya, you could do that, although it would require you to adjust your formula annually. Another wrench in that, which I’ve seen people complain about, is that deleted records do not reset their autonumber count – the number is not recovered if you delete a record, such as an accidentally created record. This can leave gaps in the sequence. The automation/scripting option overcomes this issue by making a fresh count every time a new record is added.

I don’t seem to have the same kind of resistance as you do to using automation/scripting, but if you need this to be done in formulas, then I think what you describe here is the way to do it. Do you still need help producing that formula, or do you have it?

Hey thanks for clarifying, Jeremy. I just haven’t done automation/scripting before so it will take some research, but I appreciate the info!

There are plenty of helpful people here on the forums that are happy to help you along if you choose to struggle through learning how to script. And I would contend that it is well worth your time, anybody’s time, really, to learn how to script in Airtable’s environment for the shear power and wealth of options it opens up for you. And (opinion, not fact, coming) it’s not as daunting as it seems from where you are. I recently taught my wife, who has no coding experience, how to do some scripting with JavaScript. Together, we built a fairly complex script that creates new records based on multiple conditions. She remarked that once you pick up the syntax for most things, it’s just implementing basic logic from there.

FWIW

What would the formula be for the option I came up with? Just in case someone else wants to give that a try?