9 Replies Latest reply on Jun 7, 2016 1:57 AM by siplus

    Help with script to check for error code

    john.s

      Using FM 12

      I have the following field on a record for Seniors that will be used to create an online gallery code.  The field must be unique.

       

      Field: Seniors::Phone_Primary

             Text field      

             Validation - Always

                        Unique value

       

       

      The seniors record is imported from a file provided by the school. When a senior comes in for their senior portrait we verify existing information and capture some additional info.

      The Seniors::Phone_Primary field is on a layout and data is entered when a senior comes in for their photo session.  The field has a Script Trigger - OnObjectExit run script…runs the following script

       

      Set Error Capture [On]

      Commit Records/Requests [No Dialog]

      If [Get ( LastError ) = 504

         Show Custom Dialog [“Duplicate Primary Phone Number”; “Enter a Unique Phone Number”]

         Go to Field [Seniors::Phone_Primary]

         Select All

      End If

      Exit Script [ ]

       

      I’m trying to check to see if the data entered is unique by looking for error code 504 and if not bring up a dialog to let the operator know they must enter a different phone number.  I’d then like to return to the Seniors:Phone_Primary field select all so the operator still has access to what was entered but can start typing in the new phone number.   I’m doing something wrong.  This script puts me in a loop and I have to force quit Filemaker. Note the Show Custom Dialog step has the “Commit Data” box checked under “OK” default button.

      I know I'm doing something really dumb...just can't figure out what.