Table of Contents

How to Set a Random ID

Sarto Jama Updated by Sarto Jama


You would like assign a random ID to new user sign-ups or generate coupon codes.

Since Text Formulas and Equations recalculate every time a record is updated, the random function [random()will set a different value each time.

The last step in these instructions allow for this value to be stored, so the first random number generated becomes a static ID.


If this your first time creating an app, you'll need to know some basics about adding objects, fields, pages, and views. You can start by reading our Builder Basics section

Other good resources can be found in our designing the database and building pages sections of the knowledge base.


Add a new text formula field

In the Schema section of the Builder, add a text formula field called "Random ID" to an object. We'll use the Customers object for this example:

Set text formula field to value

  1. Click to edit the Random ID text formula field.
  2. Click in the formula field and enter the random() function, with any number of characters that you want your ID to have, eg. random(7)

Store Value: Add a conditional rule to short text field

If you'd like to store the first random number generated, you can continue with the following steps.

  1. On the same Customers object, add a new short text field called ID.
  2. Click to edit the ID short text field.
  3. Click on the "Conditional Rules" tab, and then checkbox "Add conditional rules".
  4. Add a rule:
  • When "ID" "is blank",
  • Value Set "to a record value" "Random ID".

This way, it will only be set once; once ID is no longer blank, it will not reset.

The short text field that you create must be placed below the text formula field in order to be populated correctly. This is due to the order of operations when calculating equations or formulas.

Notes & Troubleshooting

Do not use the Random ID field elsewhere in your app, since it will change with each record update.

How did we do?

Generate Simple Numeric Barcodes Automatically

Calculate Age in Years from a Birthday