Creating random unique IDs that do not duplicate

After hours/days of smashing forehead into keyboard I have a working solution!

Here is my solution, however, let me know if you can find a cleaner way!

  1. First make sure your backend workflows are enabled in settings. You should now see a new button at the bottom of your pages dropdown called “Backend Workflows”.

  2. Setup a new API endpoint in your backend workflows (expose public endpoint set to “no”). Setup a key to ask for the db entry you’d like to modify.

  3. Setup the first action to modify the passed in entry, create the unique ID using Calculate Formula > Generate Random String.

  4. Setup a second action: schedule API workflow with the “only when” parameter running a search for duplicate IDs.

  5. Back at the workflow when your database entry is first created, set up a schedule API workflow action to pass in the recently created entry.

Depending on how many db entries you have, how many digits/alphanumerics you are assigning and how much time your allowing between scheduled API workflows could bring you quick or very long results… either way… your guaranteed a unique number so long as you haven’t used up all your digits.

Enjoy!

11 Likes