3 Replies Latest reply on May 22, 2012 9:31 AM by philmodjunk

    tab scripting


      tab scripting


      I have a tab control with four tabs- each tab has a different filtered portal displaying results front the same table depending on the filter. 
      I want to creat a script that will add a new record to this portal and subsequently set field to enable allocation of records to the correct tab. 
      Is there a way of using an IF/Case to depending on which tab is being viewed at the time?
      Eg if I am on the 'customers' tab i want to :
      if tab = "Trade"
      New record
      set field Clients::Type = "Trade"

      Not sure of the correct command!
      Thank you

        • 1. Re: tab scripting

          You'll need to name your tabs using the "Name" entry in the Inspector window in layout mode.  Then, assuming you have a tab assigned an Inspector name of "Trade," you can evaluate its state using GetLayoutObjectAttribute ( "Trade"; "isFrontTabPanel" ).

          There are ways to write a recursive custom function in Advanced that will dynamically find the name of the front tab panel (or all front tab panels, if you have nested tab panels or multiple tab panels on the layout), and FM12 has script triggers that could set a global variable every time the tab panel changes (for recordkeeping), but I usually consider those methods overkill.  The formula above returns 1 or 0 when you pass it the tab name you're interested in - simple as that.

          Edit: Just keep in mind that "isFrontTabPanel" reports on whether the named tab is the front tab only in the context of its own tab panel, regardless of whether that tab panel is contained within an inactive parent tab.  If you nest tabs, you'll probably want to run multiple checks if you're trying to check a sub-tab.

          • 2. Re: tab scripting

            Thank youvery much - works perfectly...

            • 3. Re: tab scripting

              Also, there are new functions and a new script trigger in FileMaker 12. If you have that version these new features provide options for working with tabs that are often much less cumbersome than the chain of IF - Else - IF's testing each tab panel in turn to figure out which one is the front panel.