4 Replies Latest reply on Feb 11, 2014 1:05 PM by brodlang

    script to run if validation error

    Svetlana

      Title

      script to run if validation error

      Post

           Hi everyone!

            

           In a database called "Logistics," I am trying to write a script that will take the user to a layout called "Customers" if the data entered into the "Customer" field is not validated upon entry (value in Customer field must be part of a value list). Haven't had too much success.

           I'm not sure if there is a script trigger that could perform the script after validation has occured (from my understanding, there isn't). Is there any way to get around this? I'm quite a novice :) Any help I can get would be greatly appreciated!

            

           Thank you.

            

        • 1. Re: script to run if validation error
          philmodjunk

               If you are using FileMaker 11 or newer, there is indeed a script trigger: OnObjectValidation that can be set on the customer field.

               If you are using Filemaker 10, you can try using OnObjectSave or OnObjectExit and you may be able to get that to work.

          • 2. Re: script to run if validation error
            Svetlana

                 Doesn't the OnObjectValidate trigger work BEFORE the data entered into the field is validated?

                 Below is the script that I wanted to run after OnObjectValidate, and I'm stumped on how to set it up properly to work. 

            Set Error Capture [ On ]

            If [ Get ( LastError ) = 506 ]

             Go to Layout [ “Customers” (Logistcs) ]

            End If

                  

            • 3. Re: script to run if validation error
              philmodjunk

                   Yes it runs before validation so you then do your own validation test. Here's code for confirming that value is member of a value list:

                   If [ IsEmpty ( FilterValues ( ValueListItems ( Get ( FileName ) ; "YourValueListNameInQuotesHere" ) ; YourTable::YourFIeld ) ) ]
                       Show Custom Value ["Value must be member of value list."]
                       Exit Script [False]
                   End If

              • 4. Re: script to run if validation error
                brodlang

                     Hey Phil,  I had this same problem and just ran across this answer of yours.  It took me awhile, but I got it working.  Just what I needed.  Thanks again for your brain.