6 Replies Latest reply on Oct 3, 2011 7:14 PM by BobSchwenkler

    Script and field focus issue



      Script and field focus issue


      I'm having a particular problem with a script I'm working on. I have a global field where I've set the Return key to "Go To Next Object" so that the user can use it to commit the data instead of entering carriage returns into the field. This field has a script trigger OnObjectExit.

      So, the user enters information, hits return, and my script runs. But what happens is that the field focus seems to be temporarily disabled for the duration of my script. Once the script has run its course, focus returns to the global field and then the "Go To Next Object" command takes place, sending field focus to whatever is next in the tab order. What I want it to do is either return to the global field or have there be no field focus.

      I can't use Commit Record in my script because only after the script is over does the field's focus return. I can't use Go To Field[originalGlobalField], because once the script is over, field focus returns, the original return command tries to go to the next object, and the script is triggered again, sending it into an unending loop.


        • 1. Re: Script and field focus issue

          What does your script actually do?

          If you end this script with Exit Script [false] it cancels out the focus change brought about by the field exit, but can't tell you if this is a good idea or not as I don't know what your script is supposed to do.

          • 2. Re: Script and field focus issue

            I'm using the script to implement a filtered portal functionality (I'm in FM 10). It's basically:

            Set Variable[$FilterText;gFilterText]

            Go To Layout[Contacts]

            Enter Find Mode

            Set Field[ContactID;$FilterText]

            Perform Find

            Set Variable[$ContactIDs]

            Go To Layout[Original Layout]

            Set Field[gPortalKey;$ContactIDs]


            As mentioned, the script is triggered by exiting gFilterText. The problem essentially is that if I hit Return from gFilterText to trigger the script, FM seems to wait until the script is entirely finished and exited before it applies the Go To Next Object command.

            • 3. Re: Script and field focus issue

              And what problem does that cause?

              None of your script steps rely on the current layout focus so this should not affect how this script executes.

              Your script as posted is missing some key details, namely table occurence names in the set variable steps and it would help to know on what table occurrence your layout is based where this script starts its executiong.

              Also, this step is missing a parameter:

              Set Variable[$ContactIDs]

              I don't know how many of these are omissions in the actual script and how many were just left out of your post.

              To post a script to the forum:

              1. You can upload a screen shot of your script
              2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
              3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
              4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional look to your script. (Use the HTML option and paste the text into the HTML editor.)
              • 4. Re: Script and field focus issue

                The problem that it causes is that I want the field focus to not go to whatever field or object is next in the tab order. It's strictly an end user functionality detail. I want either no focus or for the focus to be placed back upon the original field.

                I'll keep the script posting comments in mind, my actual script is a good bit longer and less intuitive to understand than the above simplified version, in this instance I don't think it would make diagnosis easier. Also, the issue at hand really has less to do with the script itself and more with what seems like a behavior of FM, which I'm wondering if there's a work around for.

                • 5. Re: Script and field focus issue

                  Then End your script with Exit Script [False] as I previously suggested.

                  This cancels out the original triggering event (go to next object here) and will leave the cursor in the current field.

                  • 6. Re: Script and field focus issue

                    I thought I did try Exit Script, but I'll give it another shot when I'm back in on Friday. Thanks.