1 Reply Latest reply on Sep 8, 2012 10:33 AM by comment

    Conditional Field Navigation Using Script Triggers

    richardsrussell

      Using FMPA 12.0v2 under Mac OS X 10.7.4.

       

      I'm working on a database to capture wages, hours, and working conditions for restaurant workers, many of whom are immigrants. Here are some of the variables we're interested in:

       

      Language Initial.jpg

       

      The one of interest is "Language", which is #32 in the tab order. "National Origin", right below it, is #33. Off to the right is "Language Other", which is not in the tab order at all. My objective is to go directly from "Language" to "National Origin" unless there's a check mark in "Other", in which case I want to go to "Language Other", stick in a prompt (highlighted because the entire field contents are selected), and then stop and wait for user input. This seemed like a job for script triggers, so I built one to be executed "OnObjectExit" from "Language". The desired effect should look like this:

       

      Language Expected.jpg

       

      Instead, what I get is this:

       

      Language Other.jpg

       

      As you can see, the script successfully inserted the prompt ("OtherLanguage") in the field, but then, instead of sticking around there, it continued on to the next field in the tab sequence. Here are the relevant script steps:

       

      Language Script.jpg

       

      Wherein have I erred?

        • 1. Re: Conditional Field Navigation Using Script Triggers
          comment

          Richard S. Russell wrote:

           

          the script successfully inserted the prompt ("OtherLanguage") in the field, but then, instead of sticking around there, it continued on to the next field in the tab sequence.

           

          A script triggered OnObjectExit runs when an attempt is made to exit the object. Unless the script returns False, the attempt will be executed after the script has run. You should add:

           

          Exit Script [ Result: False ]

           

          before the Else step (if the Else clause is necessary at all).