3 Replies Latest reply on Sep 20, 2010 12:28 PM by philmodjunk

    Max Function not working correctly

    BrettCox

      Summary

      Max Function not working correctly

      Product

      FileMaker Pro

      Version

      11.x

      Operating system version

      10.6.x

      Description of the issue

      I have a script that is used to create a job number by incrementally updating the number by 1 each time a new record is created.  It begins with 01 then drops the beginning 0 after 9.  This script worked in both FMP9 and 10.

      Steps to reproduce the problem

      Created a new DB with only the the fields needed to incrementally increase the number.

      Case ( Max ( Self Job Serial Count::Job Serial ) = 0 ; "01" ; Max ( Self Job Serial Count::Job Serial ) < 9 ; "0" & Max ( Self Job Serial Count::Job Serial ) +1 ; Max ( Self Job Serial Count::Job Serial ) ≥ 9 ; Max ( Self Job Serial Count::Job Serial ) +1 )

      Expected result

      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13...

      Actual result

      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 011, 012, 013...

      Exact text of any error message(s) that appear

      No error message

      Configuration information

      1 table titled "Job Records"
      2 fields "Job Serial", "Job Number"
      1 relationship "self Job Serial Count" : "Job Number" = "Job Number"

      Workaround

      Revert to FMP10

        • 1. Re: Max Function not working correctly
          philmodjunk

          Just to clarify,

          Case ( Max ( Self Job Serial Count::Job Serial ) = 0 ; "01" ; 
                     Max ( Self Job Serial Count::Job Serial ) < 9 ; "0" & Max ( Self Job Serial Count::Job Serial ) +1 ; 
                     Max ( Self Job Serial Count::Job Serial ) ≥ 9 ; Max ( Self Job Serial Count::Job Serial ) +1 )

          Is an auto-enter calculation, not a script and Job Serial is a number field not text?

          It could be a Mac OS issue, but with Filemaker 11 Adv, Windows XP, and both "Do not evaluate if all referenced fields are empty" and "Do not replace existing value..." options cleared, this auto-enter calculation does appear to work correctly.

          PS. I'd prefer to treat Job Serial as strictly a number field and define a separate text calculation field to add leading zeroes for display purposes.

          • 2. Re: Max Function not working correctly
            BrettCox

            It is a script run after a job type is entered.  Different job types receive a different prefix to the job number and are then incrementally increased by one with the job serial. 

            You resolved my issue though.  Job Serial was a text field previously.  I changed it to a number field and that resolved the issue. 

            • 3. Re: Max Function not working correctly
              philmodjunk

              Text values compare differently than number values.

              "09" is less than "9" and that's why you kept getting a leading zero.