8 Replies Latest reply on Dec 7, 2015 1:03 PM by tays01s

    OnPanelTrigger

    tays01s

      I have some tabs on the same layout where I want to stop the user moving to another tab until they've completed vital data. With some help from the forum, the reaction to the 'tab_patient' works fine. 2 things:

      1. I'm being a bit ignorant in not understanding exactly what 'Exit Script [ Result: False ]' does?


      2. And I haven't succeeded in getting the 2nd tab to react correctly.

       

      Commit Records/Requests [ No dialog ]
      If [ GetValue ( Get ( TriggerCurrentPanel );2 ) ="tab_patient" ]

      If [ IsEmpty(Patient::Lastname) ]

      Show Custom Dialog [ Title: "Complete patient info"; Message: "You must complete If(IsEmpty(Patient::Lastname);"Lastname";""); Default Button: “OK”, Commit: “Yes” ]

      Exit Script [ Result: False ]


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

      If [ IsEmpty(Calc::cm) or IsEmpty(Calc::kg) ]

      Show Custom Dialog [ Title: "Complete patient info"; Message: "You must complete critical fields before leaving this tab:"&¶ &

      If(IsEmpty(Calc::cm);"cm";"")&¶ &
      If(IsEmpty(Calc::kg);"kg";""); Default Button: “OK”, Commit: “Yes” ]

      Exit Script [ Result: False ] Else

      Go to Object [ Object Name: Get ( TriggerTargetPanel ) ]

      End If

      End If

      End If

      End If

       

        • 1. Re: OnPanelTrigger
          TomHays

          tays01s wrote:

           

          1. I'm being a bit ignorant in not understanding exactly what 'Exit Script [ Result: False ]' does?

           

          The Exit Script result is the key to stopping the user from moving to a different tab panel.

          The FileMaker routine that called your script pays attention to the Exit Script result value.

          If the result is False, the user's attempt to move to a different tab is ignored.

          If it is True, the user succeeds.

           

          -Tom

          • 2. Re: OnPanelTrigger
            Mike_Mitchell

            There's no need for the Else clause in your second example. If the triggering action isn't canceled, then FileMaker will proceed to go to the next tab panel.

            • 3. Re: OnPanelTrigger
              tays01s

              Thank you both.

               

              However, the tab_calcs part of the scrip still doesn't prevent a user moving off it without completing critical fields. Might this be because those fields are in a portal from a related table?

              • 4. Re: OnPanelTrigger
                Mike_Mitchell

                Didn't mention that before. Makes a difference. Here's why:

                 

                When you evaluate a related field via a calculation, FileMaker always chooses the first related record. So if your user is entering data in a different related record, then referencing Calc::cm won't see it. It will see that field in the first related record instead, pass the validation, and move on.

                 

                To fix this, you need to change your validation method to OnObjectExit or OnObjectSave or OnObjectModify, depending on your exact need. Or, you need to fetch all related records and loop over them using the List ( ) function, verifying proper entry. Or both. It all depends on what your business rules are.

                • 5. Re: OnPanelTrigger
                  tays01s

                  Thanks, that confirms a suspicion.

                   

                  There's a 'calc' portal on the 'tab_calcs' panel, are you saying have a script preventing movement off that object (portal) until critical fields are filled?

                  • 6. Re: OnPanelTrigger
                    tays01s

                    Actually I'd need a 'object' containing a record within the portal to refer to wouldn't I?

                    • 7. Re: OnPanelTrigger
                      Mike_Mitchell

                      The object is any field you want to verify before moving on.

                      • 8. Re: OnPanelTrigger
                        tays01s

                        I'd specified validation rangs, but forgotten 'not empty'; thanks.