5 Replies Latest reply on May 17, 2010 9:34 AM by aammondd

    How can you create a special type of serial number?

    AAgraphics

      Title

      How can you create a special type of serial number?

      Post

      Using FMP10 on Mac and PC

       

      I have a table where there is an item number.  I want a separate field to take the item number and add the suffix of "-01".  Anytime the same item number appears, I want this separate field to add the I mentioned in the previous sentence, but not repeat the number.  For example, if I had an item number of "TEST", this separate field would generate "TEST-01" and a second record that had "TEST" as the item number would then have "TEST-02" in this separate field.  This needs to auto generate based on the item number field.  Any ideas of how this is possible?

        • 1. Re: How can you create a special type of serial number?
          aammondd

          Basically you are looking at a "version" table that would store the ItemID and its current version the process would have to both update the ItemID and the Version table so I would think the best way to handle this is via a script and a seperate ItemID creation field

          This could even be a global field with a script trigger or a button to submit the ItemID  You could even have the script check and verify with the user that they indeed do want to create a new version of the item before actually doing so.

          Once verified then the script updates the item table and the version table.

           

           

          • 2. Re: How can you create a special type of serial number?
            AAgraphics

            I am somewhat of a novice, what would that script look like?

            • 3. Re: How can you create a special type of serial number?
              aammondd

              Your version table would have to be linked to your creation field so that it would be able  to retrieve the current version.

               

              If you are establishing that the suffix can only be 2 digits then you will need to  take  that into account

               

              This is just me typing it in logical fashion don't take it as code

               

              If[IsEmpty(versiontbl:itemversion)]

              SetVariable[$currversion; 1]

              SetVariable[$newversion; 1]

              Else

              SetVariable[$currversion; versiontbl::itemversion]

              SetVariable[$newversion; versiontbl::itemversion +1]

              End-if

               

              If[newversion > 99

               ShowCustomDialog Box [Version Limit Reached; "Item already has 99 Versions"]

               Exit Script

              Else

                If [$newversion < 9]

                   SetVariable[$suffixID = "0"& $newversion"]

                 Else

                  SetVariable[$suffixID = $newversion]

                End-if

              End-if

               

              optional

              Show CustomDialog Box [Item ID in use; "Do you wish to proceed with creating a new version of this Item]

              end-optional

               

              SetField[versiontbl:itemversion; $newversion]

              SetField[Itemtable:ItemID; gblItementry & $newversion]

               

              optionally you could use the variable "$currversion" in a dialog box or write it out to an audit record etc.

              thats the reason I set it so that we dont lose track of it.

               

               

               

              • 4. Re: How can you create a special type of serial number?
                aammondd

                If you use the optional Custom Dialogs you will need to use an If [Get(LastMessageChoice) =  2 (or whatever) to abort the script or whatever

                 

                The Get(LastMessagChoice) tells you which button they pushed.

                If you dont check for a cancel the script will just continue on

                 

                • 5. Re: How can you create a special type of serial number?
                  aammondd

                  One more thing if its a new Item you would have to create a new record in the version table you can do this conditionally with a check of the currversion and newversion variables being = or 1

                  you can create the new record in the version table at the time you check IsEmpty() too

                   

                  It really depends on how much you want the user to validate the decision to make a new itemid

                   

                  I also forgot the hyphen in my text string but thats an easy add.

                  If you want 3 digits its an additional if dealing with the leading zeros for single or two digit numbers (im sure some of the other text manipulation experts have a better way of doing the suffix string by some fill length function)