Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

generate random alpha-numeric pins

Featured Replies

Any good methods to generate random alpha-numeric numbers?

Certificate Field=7 digit number set by script.User determines start number and amount of records to generate.This number must be unique...

Each series will be 10,000 number increments. Unless someone sticks a 100,000 in there... So I guess it doesn't matter if pin is unique but it would be nice...

Pin Field=6 digit random numeric. =auto-enter calc =Right("000000" & Random* 999999; 6)

I want the pin to be alpha numeric...

Thanks in Advance!

The requirements for random AND unique are somewhat conflicting. You would need to generate a random number, check it against all previously generated numbers, and reject it if there is a collision. As the amount of generated numbers grows, the system slows down. It seems to me a serially incrementing number would be a better choice for numbering certificates.

To generate a random alpha-numeric code from any alphabet:


Let ( [

alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" 

] ;

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1)  & 

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1)  & 

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1)  & 

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1)  & 

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1)  & 

Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) 

) 

  • 6 months later...

I used this and an error capture on commit to attempt to create a script to create a unique six-character id. However, even after the script finishes, I get an error that says there is an existing id. It takes a few tries to get a unique id that will actually work.

I've got ten seats using the same host, and only 2 of 10 seats are wiggy about the script. I get a system error that says a unique id with that number already exists. And it does. This doesn't happen on the other machines. All using FM9.

Is it possible that there is a random seed generation problem here? Is it possible that since there is no 'while' method that the seed is only checked for the first instance? I may be entirely chasing down the wrong avenue.

If someone could produce an example script that will check to make sure my id is both valid and unique, I'd be grateful.

First and foremost: this is NOT a good method to create unique IDs.

I don't know why you're having an issue with 2 particular seats. No one knows how the Random() function works internally - not even FMI engineers, it seems:

http://fmforums.com/forum/showtopic.php?tid/195627/post/299804/#299804

since there is no 'while' method

Not sure what you mean by that. If the process is scripted, you can loop until a condition is met - I believe that qualifies as a 'while' method. If you have Advanced, you can also write a recursive custom function that will do the same.

comment,

Thanks for your reply. I would appreciate any suggestions you may have for creating a six-character random unique id. We need a short id, but numbers-only would run out in a couple years if we just auto-incremented.

As I said before, unique and random do not go well together. I'd suggest you use an auto-entered serial number as the basic ID. If you want a shorter code, just convert the numeric ID to a higher base, e.g. using "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" would enable you to go up to base 36.

See also:

http://www.briandunning.com/cf/218

That would have been my next question. I appreciate your psychic abilities. I think I can take it from here. This is better.

Cheers!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.