Oct 03, 2018 05:17 PM
Hi Guys,
I am creating a base with a column which uses the Record ID formula but having some trouble.
I want to create a unique ID for each new record with a string at the front from which comes from another column. For example, when a new record is created it draws the string BB from company name column and then adds the unique id so would end up looking like BBrecnzjghg09818 or something. Is this possible to do?
If someone also books an appointment in the future I want to be able to search the base and identify that record (individual) and so that I do not end up with a whole bunch of duplicates for an individual.
Not sure if this makes sense but thought I would reach out!
Thanks,
Mark
Oct 03, 2018 05:26 PM
Sure, you can do this with a formula field (or a couple).
First, you’ll want a formula field that creates the “Company” part of your ID string. Do this with if statements:
IF(
{Company} = "Airtable",
"AT",
IF(
{Company} = "Google",
"GL",
IF(
... etc
)
)
)
Then, in your ID field, you’ll just combine that with a call to RECORD_ID()
via concatenation like so:
IF(
{Company Initials},
{Company Initials}
)
&
`RECORD_ID()`
Oct 03, 2018 05:51 PM
Hmmmmmmm I tried the first formula and obviously I am doing something wrong here?
Really appreciate your help Jeremy!
Oct 03, 2018 08:36 PM
Hard to tell because I’m looking at your screenshot on my phone… but it looks to me like you might have an erroneous comma at the very end before the three closing parentheses.
If there are no further conditions to be processed in an IF() statement, then you don’t need additional commas, and the system is very strict about the syntax of that.
Oct 04, 2018 01:46 AM
Maybe the SWITCH()
function would be cleaner? :thinking:
Oct 04, 2018 07:32 AM
Good point… SWITCH()
would be a lot cleaner.
Oct 04, 2018 12:48 PM
Switch function works perfectly and is a lot cleaner! However, when I combine the Company ID and Unique ID with the below
IF({Company ID}, Record_ID())
It just shows the unique id and not the Company ID at the front of the string…I tried your formula Jeremy for this but it didnt want to work. Any thoughts?
Oct 04, 2018 12:50 PM
I understand why it is just showing the Record_ID but how do I combine them to show both?
Oct 04, 2018 12:51 PM
IF(
{Company ID},
{Company ID}
)
&
RECORD_ID()
Oct 04, 2018 12:51 PM
Found the answer!!
CONCATENATE({Company ID},{Unique ID})