3 Replies Latest reply on Mar 1, 2010 1:40 PM by philmodjunk

    Script to require a field input before moving on to other fields in a layout

    miw

      Title

      Script to require a field input before moving on to other fields in a layout

      Post

      I am trying to write a field script trigger for both OnObjectSave and OnObjectEnter that requires a user to select information from a pull-down menu and not leave that data field blank (they must select a data point from the pull down list) before they can go to the next field in the layout (the next field being dependent on the selection made in the prior field).  Here is what I have written so far for the script trigger for the COuntry:Country layout field:

       

      If [IsEmpty (Country:Country)]

      Go to Field [Country:Country]

      Enter Browse Mode [Pause]

      Else

      Go to Field [Country:City]

      End If

       

      However, with this script I cannot keep the input field focused on Country:Country until a selection is made; I can still tab past it to the next field.  I need the Country:Country field completed before moving on to other fields on the input screen.  How can I accomplish this via a script?

       

      Please help!

       

        • 1. Re: Script to require a field input before moving on to other fields in a layout
          philmodjunk

          Instead of OnObjectSave, I'd just set a field validation to require a value in Country::Country. That kicks in at the same moment and protects all layouts you might have from permitting a missing value in this field.

           

          For your script, use OnObjectEnter and add an Exit Script [False] step. OnObjectEnter will need to be added to all your fields if you want to keep the user from clicking into any other fields before they select this value.

           

          If [IsEmpty (Country:Country)]

            Go to Field [Country:Country]

            Exit Script [False]

          End If

          • 2. Re: Script to require a field input before moving on to other fields in a layout
            miw

            Phil:  I see your solution - a good idea - I didn't think about needing the script to all other fields in the layout.  The field validation alone would not work for me since the "not empty" requirement only works whent he record is committed.  One additional question though:  how do I get your script line "Exit Script [False]"?  I see no option for "False" and if I type it as a result the resulting line is "Exit Script [Result:False]"

            • 3. Re: Script to require a field input before moving on to other fields in a layout
              philmodjunk

              The validation rule is just to take the place of the OnObjectSave trigger and to make sure that any "holes" in your script triggers don't let the user get away with an empty field. The OnObjectEnter script trigger then catches the error at an earlier point to make things a bit more user friendly. I'd also add a show custom dialog to the script to tell the user why their cursor has popped back to the country field.

               

              Exit Script [Result:False]

               

              Is the correct syntax. I forgot that Filemaker adds in the "Result:" tag.