5 Replies Latest reply on May 27, 2012 5:24 PM by mikeo'neil

    Script Trigger on Tab Panels

    mikeo'neil

      Hi Folks,

       

      Windows 7/XP, FMA 12, FMS12

      I have a tab panel with 7 tab panels. On three of the Tab Panels, I have Chart Previews and each Panel is sorted on a different value. The problem I am having is getting each panel to sort on the appropriate Sort Script.

       

      I have set the script trigger to activate on “ontabswitch”, that calls the sort decision script.

       

      Script: (Panels are named, “Alert”, “Discharge”, & “Misc” that need to sort on a different value.

       

      Allow User Abort (off)

      Set Error Capture (on)

      If[Get(TriggerCurrentTabPanel) =”Alert”]

      Perform Script [Sort_Shift]

      Else If [Get(TriggerCurrentTabPanel) =”Discharge”]

      Perform Script [Disc_Disposition]

      Else If [Get(TriggerCurrentTabPanel) =”Misc”]

      Perform Script [“Sort_Hospital”]

      End If

       

      This is not sorting on the desired value. What simple step am I missing?

       

      Thanks,

       

      Mike

        • 1. Re: Script Trigger on Tab Panels
          BruceHerbach

          Mike,

           

          I don't see how you determine which tab panel you are on.  With out that,  it is probably running the wrong sort script.

           

          In 11 You can use an onobject modify script trigger on the tab to start the script and get(fronttabobject???) to determine which tab.  You will have to check the get function, I can't recall the exact function name and Im away from the computer at the moment.

           

          HTH

          Bruce

          1 of 1 people found this helpful
          • 2. Re: Script Trigger on Tab Panels
            datastride

            Mike,

             

            Get( TriggerCurrentTabPanel ) returns the name of the tab the user was viewing when they clicked the name of a different tab.   (i.e. the old one)

             

            Get( TriggerTargetTabPanel ) returns the name of the tab the user clicked on.  (i.e. the new one)

             

            And remember that both of these return a two-value list, with the first value being the tab number, and the second value being the tab name.

             

            Check the online help for more details.

            • 3. Re: Script Trigger on Tab Panels
              mikeo'neil

              Solved using the following:

               

              GetValue(GetTargetTabPanel);1) = 3

               

              The 1 equals the first value and if that "3" equals the Third Table panel, then sorts on the desired sort value. I guess I could also have tested for the "Name" of the Tab Panel to do the same thing but this is working as desired.

               

              Thanks Morgan & Bruce, I had overlooked the GetValue part when I looked at the online help.

               

              Mike

              • 4. Re: Script Trigger on Tab Panels
                BruceRobertson

                You are missing about quite a few things; and this has also revealed a FileMaker 12 bug.

                 

                1. As mentioned by Morgan, you are calling the wrong function.

                Get( TriggerTargetTabPanel ) returns a list of the TARGET tab panel index and (if it has one) the layout object Name of the target tab panel

                 

                2. The name of a tab panel and the layout Object Name of a tab panel are completely different properties.

                I suspect you may not have named your tab panels. The text the user sees on the tab is not the layoutObjectName of the tab.

                So for instance a result might look like this IF you have named the tab panel correctly:

                3

                Misc

                 

                3. Since the result of Get( TriggerTargetTabPanel ) is a list, if you are going to compare it to a literal text value such as "Alert" you need to get the second value from the list.

                getValue( Get( TriggerTargetTabPanel ); 2)

                 

                BUG:

                Normally when working with a FileMaker list, you can manipulate it; such as performing a substitution like this:

                Substitute( someList; ¶; ", ")

                The above expression changes all returns in a list for comma space.

                 

                HOWEVER, the result of Get( TriggerTargetTabPanel ) is not a standard FileMaker list.

                For some reason the delimiter is the enter character, char(10), not the return character, char(13).

                So the above substitution doesn't work.

                 

                The bug is noted here:

                http://forums.filemaker.com/posts/2840823ce0

                • 5. Re: Script Trigger on Tab Panels
                  mikeo'neil

                  Bruce,

                   

                  Thank You

                   

                  The script step from my previous reply had a typo, correit was  GetValue(Get ( TriggerTargetTabPanel );2) = "Alert"

                   

                  It also works using

                  GetValue(Get ( TriggerTargetTabPanel );1) = 3

                   

                  But it makes more sense to use the tab panel name which I originally had entered into the Name in the Inspector. Using the tab panel name avoids the issue of having tomodify the script when an additional panel is created.

                   

                  Mike