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

Question

Question

random number generation

asked on February 25, 2015

How can I generate a random number of say 6 digits that won't be repeated ?  We need to assign a deposit number or bill number for tracking purposes that won't be repeated.  Maybe a concatenation of the date and a random number.... is there something like %Date Rand() that could make this work ?

 

In other solutions (previous to forms) I've used the Laserfiche Entry ID, but thus far efforts to get that field to populate upon submission have failed...

 

 

0 0

Replies

replied on June 17, 2015

I faced the same problem. Eventually I decided to use the time and date stamp to generate a number for me with JavaScript.

Assign a css class to a single line in advanced. I used "qte" (see the code example).

var tel = Date.now || function() {
  		return +new Date;
		};
      $('.qte input').val(tel);

Your end result will look like this.

6 0
replied on June 6, 2019

I am able to generate the number using your example java but its not saving the data. I'm not a programmer so was wondering if there is something I'm missing.

 

 

0 0
replied on February 25, 2015

If you want to avoid repeating, random numbers are usually not appropriate.  Laserfiche entry id is a good idea, or you could do something similar with your own database table.  What Laserfiche product is this for, and how specifically did the entry id approach not work?

2 0
replied on February 25, 2015

I think when I saw process-id I thought initially this would relate to entry id.  That isn't correct.

 

What is the best way to get an unique identifier on the form ?  Even the Entry ID when it is stored ?

 

Just trying to get a unique identifier, backfilled in the form field if possible before it is locked as a TIFF...

0 0
replied on February 25, 2015

That depends on the process. For example, you could populate the unique number via a variable in the URL. Or you could populate a unique number from a lookup if you're using lookup rules.

-Ben

0 0
replied on February 25, 2015 Show version history

Hey there,

As Brian said if you want unique numbers, it's best to use a sequential number.

However, there is a to use random numbers that are practically unique. You could use GUIDs. They are rather long though. Here's a sample:

6fa4e3cd-1caa-477b-a622-d5cadb35129e

The good news is that SQL Server can create them for you with the newid() function, as can Java: Generate-uuid-in-java

According to Wiki, if you created a few tens of trillions of IDs per year, the chances of creating a single duplicate would be about the same as you personally (not just anyone) being hit by a meteorite, according to Wiki. 

What do you need the random number for?

-Ben

 

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

Sign in to reply to this post.