cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Random number generator

johnw
Executive Chef I
Executive Chef I

is there a way to create a random number?

I have a very rare use case that will require me to append something to an end of a number to make it unique.

rather than creating a variable and looping through it adding 1 (eating up tasks)

was wondering if there was some trick to just add a random number to my field to ensure its unique in this one off scenarios 

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

It's kinda silly, but "rand" isn't supported as a formula method. It works in a Ruby action though.

Make a Ruby action, add an output field called "random_number", and use this as the code:

{random_number: rand(100)}

 This will generate a random number between 0 and 99. You can update "100" to increase the range. If you want the range to start at 10000 for example, just add 10000 to the result.

View solution in original post

2 REPLIES 2

gary1
Executive Chef III
Executive Chef III

It's kinda silly, but "rand" isn't supported as a formula method. It works in a Ruby action though.

Make a Ruby action, add an output field called "random_number", and use this as the code:

{random_number: rand(100)}

 This will generate a random number between 0 and 99. You can update "100" to increase the range. If you want the range to start at 10000 for example, just add 10000 to the result.

johnw
Executive Chef I
Executive Chef I

thanks...  was hoping a formula so I wouldn't have to use a task but if this is the only way.