3 Replies Latest reply on Nov 5, 2010 1:58 PM by philmodjunk

    Bypass Validation When Running A Script

    RonCates

      Title

      Bypass Validation When Running A Script

      Post

      I have a field in a layout that has validation set to "Not Empty". On the same layout I have a field with a script trigger to run a script on modification. The script goes to another layout and deletes all related records in order to replace them with the new selection. Now, when a user triggers the script before populating the field with the validation the script proceeds to delete all records without leaving the current layout. Not a good thing. I remember seeing somewhere that a script can be set to bypass validation. Is this correct and how would I set it?

      Thanks

        • 1. Re: Bypass Validation When Running A Script
          philmodjunk

          Sounds like it is possible you are using Go TO Related records in situations where there are no related records to go to. Go To Related records, if used with follow on scripting that modifies or deletes records in the related set of records, should always test to see if there are any related records or that no error occurred before proceding with the rest of the script.

          To answer your specific question, you can use commit records [Skip data entry validation ; no dialog ] to keep the field validation from kicking in too soon.

          If you are using FileMaker 11, you might also try using the On Validation trigger as this is supposed to fire before the validation takes place, but since you are pulling up a set of related records, you may need to commit the record first so that the relationship links to the correct records anyway.

          To learn more about Go To Related Records, see here:  The Complete Go To Related Record

          • 2. Re: Bypass Validation When Running A Script
            RonCates

            Actually, I am testing before going to related records but the situation is similar in that the validation in this case prevents the goto related record step from leaving the current layout and therefor the delete all step that follows is executing on the wrong table.

            I am currently trying to impliment a solution provided by Barbara on another forum involving setting a global field at the beginning of the script and validating by calculation. I believe it will do the trick.

            Thanks
            Ron

            • 3. Re: Bypass Validation When Running A Script
              philmodjunk

              I'd like to see your script. I'm curious to see how the validation is keeping GTRR from going to a different layout without halting script execution altogether. I can conceive of a commit record being needed before the correct records are related to the current record in some circumstances...