Randomly generated ID

Hi !

I am trying to generate an unique ID code using Javascript.
We need this in order to handout an ID card to every new person visiting our services. When a person has already used our services, the code will not be generated (using a basic skip logic).
I have found this formula once(int(899999*random())+10000) which seems to be perfect because we need a 6 number identifier. However I am wondering about the probability to end up with the same identifier twice. Are the forms entered in KOBO in anyway linked to each other? Is their a way to make sure that the same number won’t appear twice? As the “once()” function a role to play in this?

Thanks in advance !

Hi @VDeom
As you may be aware, random numbers are basically mathematical functions with a defined level possible duplication. I normally minimize this by increasing the random probability e.g. doubling the random approach e.g. *once(int(899999*random()random())+10000)

I also think that this topic on unique IDs would be very helpful to you


1 Like

Maybe you could also check out the discussions that has happened in the community here for other examples discussed previously.

Thank you for the answer,

I indeed saw this article but the examples are not possible for us as we wish to keep a maximum of 6 numbers is the ID and do not collect any “personal” data other than the gender, birthdate of the person. We cannot use these data to create a anonymised code.

I will try doubling the random function then :slight_smile: