8 Replies Latest reply on May 5, 2011 2:36 PM by LaRetta_1

    Strange "Validate Always" behavior with scripted variable…

    andrewggrant

      Title

      Strange "Validate Always" behavior with scripted variable…

      Post

      I will try to explain what happened in detail. I am hoping someone can explain WHY it is happening.

      In a Table, we created a field, set to Number type, with validation set to "Always", and strict data type of Number.

      We then set a Variable ($ID_List) in a script to a number (I know variable only hold text). Next we used the script step of "Set Field" to set the newly created number field to the value of the Variable "AS A NUMBER" using the calculation:

      GetAsNumber ( $ID_List ).

      Immediately we get an error code of 502 for validation issue.

      STEP 2.

      After much head scratching, we experimented by removing the strict data type of number from the field and left validation to "Always". Still failed.

      STEP 3.

      Set the variable to a text string and changed the table field to a data type of "Text". Left validation to "Always" and removed the strict data type of number. Everything works.

      Can anyone explain why this is happening? I understand that variables only hold text and that numbers put into a variable are stored as text. When I use the function of "GetAsNumber ( $ID_List )" I expect the text numbers to be treated as actual numbers. Why isn't this working?

        • 1. Re: Strange "Validate Always" behavior with scripted variable…
          philmodjunk

          Interesting. I think you've found a bug that should be reported over in the Report an Issue section.

          If I assign a single number to a variable, I can assign it to the validated number field and no error occurs.

          Set variable [$Number ; value: 5 ]
          Set Field [Table::NumberField ; $Number ]

          If I enclose the number in quotes and assign it to the variable, I still do not get an error.

          Set variable [$Number ; value: "5" ]
          Set Field [Table::NumberField ; $Number ]

          If I use List to assign a list of numbers, I get the error.

          Set variable [$Number ; value: list ( 5 ; 4 ; 3 ) ]
          Set Field [Table::NumberField ; $Number ]

          That is all as expected. But if I use GetAsNumber to coerce the list of number values back into a single number of type number, I then get the error when I would not expect it.

          Set variable [$Number ; value: list ( 5 ; 4 ; 3 ) ]
          Set Field [Table::NumberField ; GetasNumber ( $Number ) ]

          As a work around, the following works and also suggests that the FileMaker team needs to look at the returns that separate values in a list to see where the problem lies:

          Set variable [$Number ; value: list ( 5 ; 4 ; 3 ) ]
          Set Field [Table::NumberField ; getValue ( GetasNumber ( $Number ) ; 1 ) ]

          • 2. Re: Strange "Validate Always" behavior with scripted variable…
            andrewggrant

            I want to clarify... I was not using a list but a single number.

            In this example, when validation is set to "Always" for the field Options, I receive an error every time it tries to apply the single number in the variable to the field using:

            Set variable [$Number ; value: "5" ]
            Set Field [Table::NumberField ; $Number ]

            Turn off the "Always" validation and everything works fine.

            • 3. Re: Strange "Validate Always" behavior with scripted variable…
              andrewggrant

              I also receive the error when trying to force the variable's contents to be viewed by FileMaker as a number with:

              Set variable [$Number ; value: "5" ]
              Set Field [Table::NumberField ; GetAsNumber ( $Number ) ]

              • 4. Re: Strange "Validate Always" behavior with scripted variable…
                LaRetta_1

                That is very strange, Andrew. It should work with being wrapped as GetAsNumber().  It works fine on Windows SP2, FMA 11.0v2.  What FM version/os are you using (please include updater version).

                I have tried every combination exactly as you have described including a few you haven't and I still can't make it break.  Has the file (while being hosted) closed improperly?  Is the field indexed?  If so, try change the indixing to none and uncheck auto indexing.  Leave field definitions and go back in and set it again then see if it still breaks.

                I would love to get my hands on that file if all else fails ... it is not normal behavior.

                • 5. Re: Strange "Validate Always" behavior with scripted variable…
                  philmodjunk

                  For reference, my tests were on a very similar system to LaRetta's: Windows XP SP3, FileMaker Advance 11.0v3.

                  • 6. Re: Strange "Validate Always" behavior with scripted variable…
                    LaRetta_1

                    I'm a bit behind, heh, Phil. Embarassed  I always make sure I upgrade our servers and systems at work but my home system gets neglected a bit. Laughing

                    • 7. Re: Strange "Validate Always" behavior with scripted variable…
                      philmodjunk

                      Can't imagine it makes much difference for this and the v3 update only fixed one issue on the windows side anyway (and according to frabriceN, didn't fix even that issue completely).

                      I mainly wanted to document that we've both tested this on windows just in case Andrew is using a Mac...

                      • 8. Re: Strange "Validate Always" behavior with scripted variable…
                        LaRetta_1

                        Understood and appreciated.  We still haven't ran the server updater.  We are waiting until others have tried it out ... it has taken time for us to wise up that fixing some problems usually creates others and one can jump from fat into fire if not careful. 

                        But there is no excuse for my not upgrading to v3 at home except that I knew it didn't affect me so I got lazy. At work our users are citrix so we only upgrade two citrix servers and not all 400 users (thank goodness).