Generate document ID with leading zero on Airtable

How do you use Airtable? Inventory system? CRM? Invoicing system? In any case, with these system, you may want to create your own record id in the way you want, example with combination of years and prefix.

Let’s assume that for this number: CUST-2023-00001, if we break it up, it will be:

  • CUST- the prefix
  • 2023 – Current year
  • 00001 – 5 digit running number with leading zero.

 

Here is the actions in Airtable:

1. On the data sheet it self, create a autonumber column, let’s call it CustAutoNumber.

2. Next, create a formula type column, we called it CustomerID, which is the real generated customer id. Enter the below formula:

"CUST-" & DATETIME_FORMAT(NOW(), "YYYY") & "-" & REPT("0", 5 - LEN(CustAutoNumber & "")) & CustAutoNumber

3. To break it up, it mean

  • DATETIME_FORMAT: We getting the year of the current date
  • REPT: Repeating add characters based on the length
  • 5 – LEN({CustAutoNumber} & “”): The maximum length of the running number is 5, I am using this this to deduct of the existing length of the running number, to determine how many leading zero do we need

4. Yup, you are done.

 

The function LEN() only work with Text column type, and Autonumber is Number column type. Hence to “convert” the number to text in Airtable, simple append a blank space by adding & “”, and it will treat it as text. Example:

Numeric: {CustAutoNumber}
Text: {CustAutoNumber} & “”

Tools

Leave a Reply

Your email address will not be published. Required fields are marked *

Prev
AI Showdown Google Bard vs. OpenAI GPT4 vs. AI21 Jurassic-2: Telling a joke

AI Showdown Google Bard vs. OpenAI GPT4 vs. AI21 Jurassic-2: Telling a joke

AI industry just get merrier when Google announce Bard released for 180

Next
AI Showdown Google Bard vs. OpenAI GPT4 vs. AI21 Jurassic-2: Language Round 1

AI Showdown Google Bard vs. OpenAI GPT4 vs. AI21 Jurassic-2: Language Round 1

So how well the 3 AI engines able to do with language?

You May Also Like
Total
0
Share