7 Replies Latest reply on Feb 16, 2012 3:49 PM by cortical

    Script to open a layout and point to a specfic record.

    garyshell

      I am looking at the “Time Cards” template database that ships with FileMaker. Specifically the “Record List” layout. Next to each name in the list is a button with a script associated with it. I can see that the script in this case is “Go to Record Detail”. And when I look at that script I see it contains:

       

      Script1.png

       

      (my apologies for using pictures but FileMaker won’t let me copy and paste the text.

       

      I understand what both of those lines do. The first opens the target layout. The second runs another script. That script contains:

       

      script2.png

       

      And that makes sense, it is looking to place focus on the correct text box for today’s date.

       

      But what I don’t understand is how the “Record Detail” layout was pointed to the correct record in the first place. I don’t see any sort of parameter being paced to link the record in the “Record List” layout to navigate the “Record Detail” layout to that record. I am sure there is something obvious I am missing, but… I am missing it.

       

      To be clear what I am asking for, I am trying to wrap my head around how THIS sample TimeCard database accomplishes this, not other ways to do it.

       

      Thanks in advance,

      Gary

        • 1. Re: Script to open a layout and point to a specfic record.
          gcatnine

          Both layouts show the records from the same table (Time Cards), so when you switch from one layout to the other, the active record remains  the same.

          Because the button is specific for each record line, it makes the record active.

          • 2. Re: Script to open a layout and point to a specfic record.
            garyshell

            Someone else I know who is knowledgeable in FileMaker just told me the same thing.  As I am coming from the Access/SQL world I was expecting there to be an EXPLCIT passing of a parameter from one layout to the other so the second layout would know which record to show.  I assumed each layout had its own recordset with their own "cursor" into those recordsets.  And the second layout would need to know where to positon its cursor.  Obviously that was a false assumption.  The table itself has a "cursor" (aka active record pointer) and all layouts would share that.

             

            That begs a question then. Is it possible to have two layouts, both using the same table, visible at one time?  And if so, would changing the active record in one automatically change the active record in the other?  Not sure WHY this would ever be done or even a good thing, just curious. Still trying to wrap my head around how FileMaker works. Some of the concepts are so foreign to us Acces/SQL heads.

             

            Thanks,

            Gary

            • 3. Re: Script to open a layout and point to a specfic record.
              cortical

              It is important to understand the distinction between 'table', base table and table occuramce (TO).

              Base table is the table as defined with fileds in Manage Databse.

              A base table can have mulitple representations , Table Occurances (TO, or TOC to avoid interpretation conflicts)

              It is the layots based on different TOC, of the same Base Table,  that can have different found sets.

               

              Thinking in terms of 'table' blurs the concept of found set, one tends to automatically think of all records. Table Occurances, to which layouts are assigned, can have the same Base Table, but different found sets at any given time,

               

              So the question begged, requires more accurate rephrasing: Is it possible to have two layouts, based on teh same Table Occurance, visible at one time?

              A: yes, use Windo New WIndow to see

               

              Q: And if so, would changing the active record in one automatically change the active record in the other?

              A: no, it will raise a warning saying this record can not be modied as it is being modified in a different window.

              1 of 1 people found this helpful
              • 4. Re: Script to open a layout and point to a specfic record.
                garyshell

                So in the case of the Timecard example, each of the two layouts is pointing to the same base table right?  Where are these TOC's specified? I get the concept of foundsets, they equate to a recordset in Access/SQL.  And I could pass those recordsets from one form to another.  But I don't see where these TOC's are defined in FileMaker.  I don't see how the two layouts are sharing a common TOC because the edit layout interface only lets me indicate the base table to associate with the layout.  

                 

                Thanks again, I am getting there I think.

                 

                Gary

                • 5. Re: Script to open a layout and point to a specfic record.
                  gcatnine

                  To make  it simple:

                  In the same window: layouts that display records from the same table have the same records set.

                  In different windows: layouts that display records from the same table could have different records set.

                  • 6. Re: Script to open a layout and point to a specfic record.
                    garyshell

                    So the TOC is instantiated when a layout is opened, it is not something that is "defined" by the developer.  This TOC has an underlying foundset of records based on any filtering that the layout might do.  If the layout executes a script that does a "GotoLayout" and the target layout uses the same base table, the new layout inherits the TOC from the first layout.

                     

                    Right?

                     

                    Thanks again,

                    Gary

                    • 7. Re: Script to open a layout and point to a specfic record.
                      cortical

                      When a new Base Table is created, a TOC for that table is automatically craeted in the Relationship Graph [RG]  ( File . Mange > Database... > Relationships tab

                       

                      As a deveoper, in the RG you can craete mutiple TOC i.e iteratied references/representations of the Base Table. Layouts are assigned to a TOC.

                       

                       

                      << So the TOC is instantiated when a layout is opened, it is not something that is "defined" by the developer.>>

                       

                      re the opened bit yes; the deveoper however defines a lyout to a particular TOC; on a layouy, in layout mode, Layouts > Layout Setup : General tab - layout name, SHOW RECORDS FROM

                       

                      <<This TOC has an underlying foundset of records based on any filtering that the layout might do.>>

                       

                      essentially

                       

                       

                      < If the layout executes a script that does a "GotoLayout" and the target layout uses the same base table, the new layout inherits the TOC from the first layout.>>

                       

                      No. layouts that have the same BT, can be defined to different  TOC. It is the TOC that carries the found set, and the layout is defined to  a TOC ( ie an instance of the Base Table).

                       

                       

                      Try it. Create 2 TOC in the RG from the same BT. Create 2 layouts , each defined ( show records from) to a different one of the 2 TOC

                      open 2 windows and have one display one layout( lay_a  ; TOC_a) and the other window the second layout ( lay-B ; TOC_b )

                       

                      create records in either

                       

                      show all records  on one layout (TOC_a) , find a subset on the other layout (TOC_b)