Help

Generate random hex color code

Topic Labels: Formulas
248 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Frontira
4 - Data Explorer
4 - Data Explorer

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

3 Replies 3

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.

Frontira
4 - Data Explorer
4 - Data Explorer

Pseudo-random is fine. My main motivation is just to change the color / hex code  a bit within a variation of posts.

Alexey_Gusev
12 - Earth
12 - Earth

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 🙂