Feb 18, 2020 07:50 AM
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
Feb 18, 2020 09:00 AM
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.
Feb 18, 2020 10:01 AM
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!
Feb 18, 2020 03:50 PM
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.
Feb 18, 2020 04:17 PM
Hey Nick - you’re right , it doesn’t work. I guess a sequential order of numbers will have to do the trick.
Feb 18, 2020 07:19 PM
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)
Feb 21, 2020 02:15 PM
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!
Feb 21, 2020 03:54 PM
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.
Feb 21, 2020 08:08 PM
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!
Dec 02, 2024 01:16 PM
Hey! I made a post about how to generate consistently random numbers!
Check me out: https://www.linkedin.com/feed/update/urn:li:activity:7269370700782542848/