You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Form Field to Generate Random Number

posted on January 18

I have a form that will have a 4 digit field that needs to be randomly generated when the form is open. 

 

Is this possible?

0 0
replied on January 18

Hi Bill,

There are two general approaches you can take. Consider if it's a requirement for this four digit random number to be unique across form submissions, and if so, if four digits is sufficient.

  1. You can use JavaScript customization in the Forms designer to generate and populate your field with a random number. See: https://www.w3schools.com/js/js_random.asp
     
  2. Use a Forms lookup to invoke a SQL stored procedure that generates a random number, checks it against a table of previously used numbers, if it's unique, writes it to the table and returns it to Forms, and if it's not, generates new numbers until it gets a unique one. Though that might not be the exact SQL logic, hopefully the intent is clear.

 

Cheers,
Sam

 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.