Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Random Numbers

Bethel SD

Recommended Posts

As part of maintaining our districts phone system we have to maintain long-distance authorization codes. In the past, the numbers were simply ran through a database and each code was increased by one. Needless to say, our staff figured it out.


I'm now using the random number generator in FileMaker; however, I'm noticing that some of my numbers have preceding zeros. Is there anyway to customize random numbers in terms of if it should or should not contain a preceding zero, length, etc.?


Thank you ahead of time for your response.

Link to comment
Share on other sites

Script = Set Password


Show All

Go to record request first


Set Field [Password_Field, Right("0000" & Random* 9999, 4)]

Go to record request next [exit after last]

End loop


This will set a 4 digit random number if 5 digit

do this for Set field


Right("00000" & Random* 99999, 5)

Link to comment
Share on other sites

Thank you for the reply. Your solution worked well for the most part, but I still received preceding zeros -- this is a problem because our phone system doesn't recognize preceding zeros when long-distance phone codes are entered.

Link to comment
Share on other sites

Password Checker = calc = Case(Left(Password,1)=0,1& Right(Password,4),Password)


Use Password checker instead of Password


Callc if leading zero replace first character with 1 and use last four characters of password, Else use entire password.


Odds of duplication by replacing 0 with 1 depends on number of users.

Link to comment
Share on other sites

If you just want to strip off any leading zeros, then the TextToNum( ) function will do that quite effectively.


For example, TextToNum(00005) will return 5.


However if, as Chopper has assumed, you want to replace the leading zeros with some other number or character, you could use:


Right("111111111" & TextToNum(YourNumber), Length(YourNumber))


...which will return 11115 when 'YourNumber' is 00005, and will return 11555 when 'YourNumber' is 00555 etc. In other words, it will dynamically replace multiple leading zeros. wink.gif

Link to comment
Share on other sites

  • Create New...

Important Information

Terms of Use