# How to generate a random number or string

There are two easy ways to generate random numbers or strings. These methods are useful in many cases, but depending on the requirements, may not be cryptographically secure.

Random numbers are helpful in a number of situations, particularly for assigning tasks randomly. Check the Assign tasks to a random person in a group article.

## Use Field Formulas to create a random number

Use the Field: Field Formulas action to generate a random number using Javascript.

Set the **Javascript code to calculate fields** field to `result = Math.random()`

to generate a random decimal between 0 and 1, such as `0.44637348688935763`

or `0.8944293544406741`

.

✅ **Heads-up:** Because of how the field formulas action works, this outputs the decimal into a text field. Use an action like Field: Set value of a decimal field to convert it to a decimal field type.

## Use Field Formulas to create a random string

You can generate a random string by using a Field Formula and the globally available field `run.runID`

from your instance.

Set the **Javascript code to calculate fields** field to `result = run.runID.split("-")[0]`

to split off everything in the runID before the first hyphen. For example, if the runID is `93d533fb-5328-44c0-976b-e34123fbba1a`

, the random string would be `93d533fb`

#### Thanks for your feedback

We update the Help Center daily, so expect changes soon.

#### Link Copied

Paste this URL anywhere to link straight to the section.