9 Replies Latest reply on May 3, 2017 12:12 PM by tays01s

    Tab navigation


      I am trying to set the first record in 2 related portals and the layout of a related table using an OnObjectModify trigger for the panel:

      Go to Object [ Object Name: "calc 2" ]

      Go to Portal Row [ Select; First ]
      Perform Script [ “Select Calc IO” ]


      This does the job but gets stuck in a loop because of the OnPanel script trigger:


      Commit Records/Requests

      [ No dialog ]
      If [ $$Cancel_StayOnTab=1 ]

      Exit Script [ ] End If

      If [ GetValue (Get(TriggerCurrentPanel);2)="tab_calcs" and

      IsEmpty(Calc_n::cm) or IsEmpty(Calc_n::kg)

      Show Custom Dialog [ Title: "Complete Calc info"; Message: "You should complete critical fields before leaving this tab:"&¶ & If(IsEmpty(Calc_n::cm);"cm";"") &¶ &
      If(IsEmpty(Calc_n::kg);"kg";""); Default Button: “Complete”, Commit: “Yes”; Button 2: “Switch tab”, Commit: “Yes” ]

      #Get(LastMessageChoice) results in True/False #Choosing 'Complete' (=1) = False and causes Exit. Exit Script [ Result: Get ( LastMessageChoice ) = 2 ]

      Else If [ GetValue ( Get ( TriggerCurrentPanel );2 ) ="tab_patient" and

      IsEmpty(Patient::Lastname) or IsEmpty(Patient::Firstname) or IsEmpty(Patient::Health_ID) or IsEmpty(Patient::Unit) or IsEmpty(Patient::Ethnicity) or IsEmpty(Patient::BirthDate) or IsEmpty(Patient::Sex)

      Show Custom Dialog [ Title: "Complete patient info"; Message: "You must complete critical fields before leaving this tab:"&¶ & If(IsEmpty(Patient::Lastname);"Lastname";"") &¶ &

      Default Button: “Complete”, Commit: “Yes”; Button 2: “Switch tab”, Commit: “Yes” ]

      Exit Script [ Result: Get ( LastMessageChoice ) = 2 ]



      I tried using the following top/tail script lines to the first script steps but without success:

      Set Variable [ $$Cancel_StayOnTab; Value:1 ]

      Set Variable [ $$Cancel_StayOnTab; Value:0 ]


      How do I avoid this loop?

        • 1. Re: Tab navigation

          I'm a bit confused by your description of the problem. At the start, you say that you are using OnObjectModify. In another you refer to what would seem to be "onPanelSwitch".


          They are not the same trigger and only one of them may be "canceled" by exit Script [false]


          Which are you using?

          • 2. Re: Tab navigation

            I have to admit, I've got 3 script triggers:

            1. OnObjectModify: To set the portal records.

            2. OnObjectExit: To hide a keypad.

            3. OnPanelSwitch: To stay on tab.

            • 3. Re: Tab navigation

              Note that focus changes brought on by OnObjectModify cannot be canceled by Exit Script [false] as the script is triggered only after the panel switch event has been processed. I believe also that OnPanelSwitch will be tripped first and that script will run before OnObjectModify--which may never be tripped due to an ExitScript [false] step being executed that then cancels the event before OnObjectModify can be tripped. That may already be clear to you, but I'm sort of thinking out loud as I type here....


              So OnobjectModify performs the first script shown? And what does "Select Calc IO" do?


              And does OnPanelSwitch perform the second script?


              And is OnObjectExit set on a field or other object inside the tab panel or on the panel itself?


              Have you tried watching all of this happen in the debugger that you can use if you have FileMaker Advanced?


              Right now, I'm thinking that you really ought to modify your scripts so that you either use OnPanelSwitch or OnObjectModify, not both.

              • 4. Re: Tab navigation

                1. OnObjectModify: This sets 1st a 'Calc' portal to the first record and then the 'IO' records related to this calc are set to the first record in the 'IO' portal. Both portals are on the Patient layout to which their tables are related..

                2. OnObjectExit: To hide a keypad > I've deleted this, but it was on the tab object; as were all 3 scripts.


                I've tried simplifiying all this to an OnPanelSwitch: To 'stay on tab' but with these lines added:

                Set Variable [ $$Cancel_StayOnTab; Value:1 ]

                Go to Object [ Object Name: "calc 2" ]

                Go to Portal Row [ Select; First ]
                Perform Script [ “Select Calc IO” ]

                Set Variable [ $$Cancel_StayOnTab; Value:0 ]

                This succeeds in not looping and does correctly set the Calc and IO portals to their respective 1st record, but causes a problem just solved in another post to return. That is, when I'm on the Patient tab, it switches to the Calc tab when triggering the above lines, then back to the Patient tab.

                • 5. Re: Tab navigation

                  My last suggestion doesn't work, not surprisingly. What I'd really needed was for:

                  Set Variable [ $$Cancel_StayOnTab; Value:1 ]

                  Go to Object [ Object Name: "calc 2" ]

                  Go to Portal Row [ Select; First ]
                  Perform Script [ “Select Calc IO” ]

                  Set Variable [ $$Cancel_StayOnTab; Value:0 ]

                  to trigger 'OnObjectEnter' as I press the 'Calcs tab' which is where the portals reside. However, I noticed from a previous Phil post that you suggested OnObjectModify to trigger scripts for tabs.


                  NB. The previously mentioned 'Stay on tab' script has an Exit script step if $$Cancel_StayOnTab = 1.

                  • 6. Re: Tab navigation

                    Putting the script to set the portal records at the beginning of the 'Stay on tab' script appears to do the job.

                    • 7. Re: Tab navigation

                      Beware of the infinite script triggers! These can be impossible to debug without FileMaker Advanced and are as much fun as the infinite loop without an escape clause with Allow User Abort OFF. Also a friend of the alert/alarm repeating nightmare when new windows are created....


                      Before embarking on journey filled with script triggers, try to use FileMaker Script Steps and layouts and see if you can do what you want that way. Complexity is like building a house with playing cards. It looks nice until you want to swap out the queen of hearts on the second row with the jack of diamonds.

                      • 8. Re: Tab navigation

                        OK, I forced myself to scan your script.


                        Why are you trying to be so complicated?


                        Before triggers we would do it this way.


                        Data Entry layout one:

                        Button: Continue

                        Button: Cancel


                        The Continue button would have a series of verification steps:

                        1: Field a has valid data

                        2 Field b has valid data



                        Each is checked with an if or a case step

                        If a validation fails

                        Alert: please fill in field x

                        go back to layout.


                        Today I would use conditionals to color fields requiring data with a light green color. This lets the user know that data is required before clicking the aggravation You Failed button although the above checks are still in use. Conditional colors are friendlier and puts the user in control rather than the script.


                        IF all systems are go, then we move to the next layout.


                        Simple and easy to work with.


                        This method requires about 10% of the labor of triggers and tabs and is finished in 10% of the time at 10% of the cost. You can spend the time and money saved on a nice vacation.

                        • 9. Re: Tab navigation

                          I may revisit this if I move away from using tabs; as Beverly pointed out, they can be inflexible. In which case button-based navigation may well be the better option.