3 Replies Latest reply on Jan 13, 2015 4:46 PM by philmodjunk

    On Layout Focus Event



      On Layout Focus Event


      We have a need to wire up a script to run whenever a layout gets focus.  Essentially it needs to update a Global variable that stores the OrderID.  We are converting an existing system, and users are able to have multiple orders open simultaneously.

      In any event...I don't see an event that triggers when a layout receives focus.  The OnOpen does not achieve what we need.  So, I am considering hooking a script to all 250 controls on the layout.  Before I proceed with that, I wanted to see if there is a better way.

        • 1. Re: On Layout Focus Event

          Open layout setup for the layout and select the script triggers tab. Set up the OnLayoutEnter trigger to perform this script.

          • 2. Re: On Layout Focus Event

            That event happens before the Find is performed...so the result is that the OrderID is always the 1st OrderID in the Table.

            I probably have some old mental-baggage...but I am accustomed to opening a form/layout with the data already filtered to the OrderID I've chosen.  It seems like FileMaker has to work much harder to select all the records, display them...and then filter afterwards.

            • 3. Re: On Layout Focus Event

              Of course that event happens before the find is performed. There is no find to perform until the script performed by this script trigger performs it. And you can't perform a find--either manually or via script until you first establish a table occurrence context for that find by going to a layout.

              All layouts in FileMaker are based on a specific Tutorial: What are Table Occurrences? "box" in Manage | database | Relationships. This is what is selected in the Show Records From drop down found in Layout setup and also in the New Layout Wizard.

              For a given fileMaker window, each table occurrence has "Found set" that consists of a subset of all records in the table occurrence's data source table, a "current record" and a sort order (if you consider "unsorted" one possible sort order).

              Every layout that has the same table occurrence, shares the same found set. Found set's can be produced by:

              Performing a find--either via script or manually performing a find
              Performing a "quick find" using the quick find box or its equivalent script step
              Show All records--makes a found set of all records in the table -- this can be scripted
              Show Omitted Records Only--swaps the current found set for all the records that currently aren't in the found set. This can be scripted. This can produce a found set of zero records.
              Go To Related Records--a script or a button option. Uses a relationship to produce a found set for the specified layout's table occurrence.

              And the omit records and omit multiple records menu options/script steps can alter the current found set by moving records out of the current found set.

              And if you open a new window, you get a whole new set of possible found sets for all of your table occurrences.

              These found sets are retained from the last window closed when you are using a a single user file on your computer. They are not retained when the file is hosted via FileMaker or Server on another computer.