Hi Community!
I would like generate with a formula a random hex color code for each new record in a database. How can I do that?
Thank you for your help!
Stefan
Hi Community!
I would like generate with a formula a random hex color code for each new record in a database. How can I do that?
Thank you for your help!
Stefan
If you want a truly random system, you will need a script. Put the script in an automation that runs when the record is created.
If you are okay with a pseudo random system, it is theoretically possible to generate a hex color code from the record ID, but that would be a very long, complex formula. I think that a script would be easier.
Pseudo-random is fine. My main motivation is just to change the color / hex code a bit within a variation of posts.
Hi,
It's an interesting question, a translation between numeric system from base 62 to base 16
I would get last char of RECORD_ID(),
4*FIND(LEFT(RIGHT(RECORD_ID(),1)),
'abcdefghijklmnopqrstuvwxyz'&
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'&
'0123456789')
4 - to get a range from 4 to 248
then get 2 chars:
mid('01234567890ABCDEF',X,1)
where X
1+int(Y/16)
1+mod(Y,16)
where Y is upper formula.
and then repeat two times, changing number 1 in upper formula to 2,3
the result should look quite complex. but nothing ever easy 🙂
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.