Dec 13, 2018 02:18 PM
Hi, I want to post a job that I’m looking for someone we can create us a solution that we can have a random 4 numeric digits, that we want to have a random unique combination of four digits, the “0” ( or “00”, “000”) can not be in the beginning, in practical, when I create the records on the column, for example “Book” is the first column (primary key in airtable), the records will be “Book 1”, “Book 2”, Book 3"….and I want whenever I create a new records, for instance “Book 4”, there would be generating the random unique combination of four digits automatically on column “ID”, please see the image I’ve attached.
I need some excellent folks to help.
Let’s try to make this happen.
Dec 13, 2018 03:37 PM
Maybe this helps?
Dec 13, 2018 03:51 PM
thank you, I looked this post, but the consequential answers are “impossible”, folks didn’t provide a solution in the end.
Dec 13, 2018 06:04 PM
If you have an Airtable Pro plan, the batch update block can be used to generate random numbers in number fields. It might not work for your specific use case (since batch update will only generate new numbers when pressed, not automatically) but it might be helpful.
Dec 13, 2018 07:09 PM
Ha! I had no idea that action existed in the Batch update block!
Dec 13, 2018 07:50 PM
Thank you, however, I don’t’ think this is the solution I’m looking, 1) this solution would only apply on the existed records, I will be constantly updating the new records, if I press the generating again, all the digits will be re-generated again, I’m using this for the stock needs, so i would want the unique ID for each item permanently…
Dec 14, 2018 12:40 AM
Ah, I missed the unique part there. Sorry about that!
Dec 14, 2018 02:28 AM
Yes, unique is important
Dec 14, 2018 09:49 AM
hi @Katherine_Duh , the batch update block cannot provide the unique value:(
Dec 14, 2018 10:04 AM
The trick is to generate all 1000 random numbers first. After that create a table with an ‘Autonumber’ as the primary field that can be used later for a look up.
Then create 3 fields (that will likely be hidden later) book_autonumber and rand_autonumber just copy the former into the later. Next create ID as a lookup field.
The solution is a little janky and requires an extra table. That said, it seems to accomplish what you need.
ps. I realized you needed to get rid of any number with leading zeros. Just create a filter to find and delete these:
where ID < 1000
[edit: added post script]