Generating a "random" number in your app

Answered

We found a simple way to generate a "random" number in one of your apps- this could be helpful if you want to generate a unique identifier on the fly for your submission-  while we can't generate an actually "random" number, we can generate a numerical string that can be essentially random.

Here's how you'll want to set it up:

First, set up a date field, and uncheck "mobile visible" in the "more" menu to keep it in the background of your app:

 

Then, create a time field, set the style to HH:MM:SS, and uncheck mobile visible:

Then, to create your "random number generator" you'll create a calculation field and multiply the date and the time field:



Once you've done this, your generator will be ready to publish!  You'll get something that looks like this:

How it works:

The number generated isn't truly random- it is always going to be a product of the date times the time, converted into an integral numeric string.  Because you're using the HH:MM:SS style for your time field, while it is technically possible for the number to duplicate between different users, they would have to generate the number within the same second and date to have an identical number.

1

Comments

2 comments
Date Votes

Please sign in to leave a comment.

  • It seems like the calculation field is only using the hour for the calculation.  I'm trying to produce a random number generator that feeds into a conditional screen that randomly selects a submission for inspection by a senior staff member. It seems like every calculation generated during the same hour has the same result. 

    0
  • Hi Brian,

    Sorry for the delay on this. Can you make sure the time field is set to have the Style be HH:MM:SS? I just set this process up again from scratch to make sure and it was still working for me when set up as described. If it's still not working for you, I can convert your request into a ticket so I can dig into your actual app a bit. Thanks!

    0

Didn't find what you were looking for?

New post