Auto Generate Random Number

Hello all,

I’m trying to figure out a way to randomly generate a 6 digit randomized number for confirmation use on future bookings. So far I’ve come up with using ‘Autonumber’ and a formula to add six 0’s as a prefix. However, I’d like the number to be completely random.

Does anyone have any input on how to achieve this or if it’s possible on Airtable?

Thank you!
Alex

1 Like

Does it have to be 6 digits? Using the record id is a good way of generating random codes that are required for identifying the record for later use. They are alphanumeric though and, even if you strip out the preceding “rec”, they are 14 characters long.

Not at all! That’s a great idea though!! Then I can use a formula to strip away the letter and return #'s only. I think that doable. Is it not?

Thanks!

I’m actually not sure if you can…just did a sweep of the formulas and I couldn’t really find a way. The Record ID way might not work if you need a uniform number of digits… it would be great if the Autonumber field type just had a variant for “Unique ID” where you could specify number of digits.

Hey Nick - you’re right , it doesn’t work. I guess a sequential order of numbers will have to do the trick.

1 Like

You might be able to use the scripting block but my JavaScript is about as good as my Portuguese (which is not say não muito bom)

Didn’t know that was an option. Will have to look into it.

On another note, do you happen to know if it’s possible to set a formula to return the following:

IF “Trip Name” is “Paris”, AND departure date is greater or equal to 90 days, AND “Room Type” is “Single Room”, then return “Trip Deposit Amount” + $350, IF “Trip Name” is “Paris”, AND departure date is greater or equal to 90 days, AND “Room Type” is “Shared Room”, then return “Trip Deposit Amount”, IF “Trip Name” is “Paris”, AND departure date is less than 90 days, AND “Room Type” is “Single Room”, then return “Trip Full Amount” + $350, IF “Trip Name” is “Paris”, AND departure date is less than 90 days, AND “Room Type” is “Shared Room”, then return “Trip Full Amount”, ELSE “Blank”

Trying to set up this variable for booking vacations based on variable dates and room types.

Do you have any insight on which formulas to use to get this?

Thanks!

@Alex_Cristian

Yes, it is possible.

Here is one method: put each situation in its own IF, and then concatenate them using the & operator.

IF( AND(condition1, condition2, condition3), 
    {Trip Deposit Amount} + 350, 
    ""
) & 
IF( AND(condition4, condition5, condition6), 
    {Trip Deposit Amount}, 
    ""
) & 
IF( AND(condition7, condition8, condition9), 
    {Trip Full Amount} + 350, 
    ""
) & 
IF( AND(condition10, condition11, condition12), 
    {Trip Full Amount}, 
    ""
) 

I also suggest using a code editor, such as Notepad++ to write your formula. It will make things like matching up opening and closing parentheses much easier. You can also break the formula up across multiple lines.

By the way, when you have a new question on a different issue, it is best to start a new topic so that it is easier for other users to know that you have a new issue.

Thanks so much! This was perfect!! I’ve never used the concatenate function before, but now that I have, it makes so much more sense to make use it. So awesome! Thanks again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.