Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 3759 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I need a way to create 2000 unique 5 digit random numbers that do not being with a zero. I am trying to generate them with a looping script but I am running into two problems. The first problem is that I keep getting duplicates which throws up and error because of the unique validation that I have set for the field. The second problem is that the 5 digit number cannot begin with a zero.

 

This is my current calculation:

SerialIncrement ( "00000" ; Int ( Random * 99999 ) )

Ideally I would like the script to automatically recreate another number if it encounters a duplicate instead of throwing up an error.

 

Any help would be greatly appreciated.

 

Thanks.

Posted

To generate a random 5-digit number that does not begin with zero (i.e. an integer between 10,000 and 99,999, incl.) =

Int ( Random * 90000 ) + 10000

To eliminate duplicates, you must compare the new number with a list of numbers generated so far and add the new number to the list only if it's not already there. With only 2,000 numbers to generate, you could keep the list in a variable and use the FilterValues() function to make the comparison. Once you have the required 2,000 values, exit the loop and move to creating a record for each value in the list (assuming that's where you need them).

  • Like 1

This topic is 3759 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.