5 Replies Latest reply on Mar 28, 2012 10:39 AM by philmodjunk

    Error Capture



      Error Capture


      I have a field (Customer Choice) which is a drop down list, from a value list of customers names (field from another table). The filed is set to validate as a part of that list. If the user enters something different, he gets a "...designed to contain only specific values" dialogue. At that point I'd like a script to be triggered to direct them to the contact list to add another card. 

      I have a Script trigger in the Customer Choice field (onExit) which attempts to cature a 506 error code when a name is entered that is not in "the list". However, the error code after the "...designed" dialogue is "0" . Is there a way to capture the 506 code to triugger my script?

        • 1. Re: Error Capture

          The reason that you can't trap this error is that the script is not performed until after the validation error message pops up and since this validation error message does not trigger an error, this overwrites the error code with a 0.

          Try using a script like this with the OnObjectValidate trigger:

          Set Error Capture [on]
          Commit Record [no dialog ] //trips the error, but with error capture on
          If [Get ( LastError ) = 506 ]

          • 2. Re: Error Capture

            Thanks Phil. That was my first guess (that the error disappears after the validation dialogue is delivered). I am using FMP Advanced 10 and I do not find a OnObjectValidate trigger. Is there another trigger event that would work?

            • 3. Re: Error Capture

              OnObjectValidate is a newly added feature in FileMaker 11.

              In that case, you'll need, unfortunately, to remove the field validation and script your own. Here's a test that is true only if the data entered is found in the list of values from the value list:

              ValueCount ( FilterValues ( valueListItems ( Get ( FileName ) ; "valuelistnameInQuotesHere" ) ; YourTable::YourDropDownFieldHere ) )

              You can put that expression inside a script performed by the OnObjectSave trigger and use Show Custom Dialog to pop up an error message that provides the user with an option to create a new record when the name entered is not found in the value list.

              • 4. Re: Error Capture

                Phil - Thanks! Works perfectly. Now all I have to do is study the solution for a while to understand the approach.

                • 5. Re: Error Capture

                  Definitions and syntax for each of the functions used can be found in Filemaker help. If you read about them there and still have questions, feel free to post them here in the forum.