7 Replies Latest reply on Jan 28, 2013 2:55 PM by philmodjunk

    Generate a Random Number

    JakeH

      Title

      Generate a Random Number

      Post

           Hi

            

           I'm in need of some help.

           Could someone send me a database or tell me a way to do this im quite new to filemaker but i love it.

            

           Tables:

           generate - Will have the random number and intial into it.

           used - Will contain the random number and intial (e.g. JH748574) so it cant ever be generated again

           data - Will contain data about the user and also the random number and intial (e.g. JH748574)

            

           Field:

           id - Field name for the random number and intial (e.g. JH748574)

            

           I need to create a database where i can enter an intial into a box (e.g. JH) then i press a button that generates and 6 digit random number and then it combines the intial box with random number generator box to generate a code like this (e.g. JH748574).

           Then once that number has been generated put it in 2 different tables (used and data)

           The id's in used must never be generated again from the generated  (how can this be done?)

           The id's in the data table will be put into the id field but these need to be in a list.

           (e.g.               id                         name                      nickname)

                           JH748574                Jake                         Fluggey


           Thanks Jake.

        • 1. Re: Generate a Random Number
          philmodjunk

               How will you use this value once generated?

               A simple auto-generated serial number can be used to uniquely identify records without needing this random but not quite random value.

               And in FileMaker 12, you have the option of using Get ( UUID ) to uniquely identify records.

               I can think of at least two ways to do this, but hesitate to suggest either when there seems to be much simpler options for what you want that do not require generating this type of value.

          • 2. Re: Generate a Random Number
            JakeH

                 Hi PhilModJunk

                  

                 Thanks for the rapid reply.

                  

                 What i trying to do is get a custom made iphone app to scan a number and locate that number from the filemaker database and bring back the data relating to that ID back to the iphone.

                  

                 Thanks Jake.

            • 3. Re: Generate a Random Number
              philmodjunk

                   But why does this require a Random number for the ID code?

              • 4. Re: Generate a Random Number
                JakeH

                     Hi

                      

                     I thought that this seems the most logical way? like i said im quite new to filemaker what would you suggest?

                      

                     Thanks

                • 5. Re: Generate a Random Number
                  philmodjunk

                       It seems to me that the key detail is that the ID number must be Unique, not that it be random. Note that you have to make sure that a given ID is not used more than once.

                       How will your app work?

                       Will this value need to be unique for all records on this one iPhone or must it be unique over records distributed over several different devices?

                       If it need be unique only for the records on a single iPhone (or a single database that the iPhone(s) connect to as clients via 4G or WiFi), an auto-entered serial number field is all you need. This remains the simplest, most reliable way to get a unique identifier--what we call a "primary key".

                       If these records may be distributed over several different devices, a text field with an auto-enter calculation that enters Get ( UUID ) will be the better option.

                  • 6. Re: Generate a Random Number
                    JakeH

                         Yes thats exactly what i meant haha sorry Primary Key

                          

                         The app will scan a number off of something and hopefully locate the ID number in the databse and bring back the data to the iphone.

                          

                         It will need to unique over records distributed over several different devices.

                          

                         I'm trying to remove the need to enter data into the database could you send me a demo off the auto-enter calculation or point me towards a download?

                          

                         Thanks

                    • 7. Re: Generate a Random Number
                      philmodjunk

                           I cannot, but you simply need define a text field in your table and use the following expression as an auto-entered calculation in Field Options for that field:

                           Get ( UUID )

                           This requires the latest version of FM Go. FileMaker Go 11 does not have this option.