5 Replies Latest reply on Aug 9, 2013 8:02 AM by sechrisman

    Script Trigger for Next or Previous Buttons

    sechrisman

      I am using script triggers to have users go to different parts of my forms in FM Go. Scripts running behind buttons works fine. But the same scripts behind a drop down list field do not work. A basic scenario is "if customer = X, then when at field10 go to field15, Else go to field11". If the user of the form changes a value in field10, then the script works (script running under "OnobjectModify"). If the user presses the NEXT button at the top of the scroll-wheel/value list, the script is never triggered. I've set the script to run under "onobjectExit", but nothing happens. Anyone else having this problem?

        • 1. Re: Script Trigger for Next or Previous Buttons
          Mike_Mitchell

          I believe your strategy is basically correct; OnObjectExit is the correct trigger to use. What you're missing is that the script won't override the normal tab order built into the layout. Hence, the app is obeying your command to go to the correct field, but then reverts back to the default tab order. If you turn off the default tab order, you should be able to get it to do what you want.

           

          At least that's how it works in my tests.

           

          HTH

           

          Mike

          • 2. Re: Script Trigger for Next or Previous Buttons
            sechrisman

            Mike, thanks for the quick response. Let me add a few details.

             

            My inspection form has about 80 fields of information, so using the built-in tab order helps a lot. I understand your concept about removing the default tab order. But if I do that, then the user will not be able to use the built-in "next" button to go from the prior field to the field where my original script is running. If I continue with example above, they can't go from field 9 to field 10 using the built-in tab order and "next" button.

             

            Though I am not going to remove all of the tab orders and make 80 custom go to scripts,  I did do a test of your suggestion and it did not work.  The go to field scripts fire on the onobjectmodify (if user changes a value), but not when they press the "next" button (where the script "should" run under the onobjectexit script trigger).. 

            • 3. Re: Script Trigger for Next or Previous Buttons
              Mike_Mitchell

              Hm. Seems the tab order fires after the script, which is causing it to revert back to the original field if all the tab orders are removed. (I didn't test that.)

               

              Okay, I played with this for a few minutes and it's doable, but it'll probably be best to change the paradigm a bit. You'll want to set up some OnObjectEnter triggers on the fields you don't want it to go to (i.e. the ones you don't want next in the tab order) in addition to (or perhaps instead of) the OnObjectExit triggers.

               

              This will be very dependent on exactly the effect you want, but basically, if you want people to jump from field A to field B normally, unless condition C is true, what you'll want to do is say, "On entering field B, jump to field D if condition C is true." That will basically allow the normal tab order to function, but be bypassed by your trigger if the condition is true.

               

              The downside of that is, obviously, if you should want to allow users to enter field B even if condition C is true. In such a case, you'll need to set an OnObjectEnter trigger to save the name of the last field entered (perhaps in a variable) and allow the cursor to go into that field if they came from an allowed location (instead of field A).

               

              Hope that makes sense.

               

              Mike

              • 4. Re: Script Trigger for Next or Previous Buttons
                keywords

                I have played around with this issue a little. Mike is right that if the trigger is OnObjectExit the tab order seems to override the script. The following script will work if it is triggered OnObjectMODIFY, but not OnObjectEXIT:

                 

                If [ "first condition" ]

                Go to Next Field

                Else If [ "second condition" ]

                Go to Field [ yourTableName::textField 2 ]

                Else

                Go to Field [ yourTableName::textField 3 ]

                End If

                • 5. Re: Script Trigger for Next or Previous Buttons
                  sechrisman

                  Thanks Mike and Keywords: Users will have to go into this field often enough, so looks like any code will not work 100% of the time. I'll stick with the original method, which is to have a separate button, between field 10 and 11, that user will press to go to area where field 15 is located. Not as elegant as automated code, but it gets a passing grade for now.