2 Replies Latest reply on Sep 10, 2016 5:56 PM by cortical

    Any suggestions on adding a new record to a subtable?

    user26705

      I am working on a system that allows guests to be registered when they enter a data center.  The solution has two tables - one to register the guest and one for the visit details. This allows a single guest to have multiple visits.  There is a relationship between the tables that I defined.

       

      The current layout uses a portal and my hope is that the user could hit the "new visit" button and enter a new visit for that user in the portal.  I have "allow new records..." checked in portal setup.  I realize that due to the layout of the portal I cannot see the blank record and portals don't seem to support a tab.

       

      I have created a script that does the following:

       

       

      Set Variable [$GuestID; Value: GuestRegistry::GuestID]

      Go to Layout ["VisitDetails" (VisitDetails)]

      New Record/Request

      Set Field [VisitDetails:GuestID; $GuestID]

      Go to Layout [original layout]

       

      ...that script runs - the actual layout opens...as opposed to just creating a new record in the portal.

       

      At the end of the day I don't care if I use a portal...I simply just want one screen where I can add new visits to the sub-table - all ideas are welcome and appreciated.

        • 1. Re: Any suggestions on adding a new record to a subtable?
          philmodjunk

          What you describe should do the job, but you might sort your portal records to put the most recently added portal record into the top of the portal. You can sort in descending order on an auto-entered serial number or a timestamp field that auto-enters the creation time stamp. And you can remove the "create" option from your relationship as you don't need it.

           

          If you don't want to change layouts, there's another option that is well documented and easy to find if you web search for it. Look up "MagicKey". This option would use a relationship between a global field in your parent table and a second occurrence of the related table with the "create" option enabled. You can then use Set Field to create the new portal record without changing layouts. This has the advantage of not changing any of the focus setting on the current layout and avoids the chance of tripping a script trigger when you exit/enter layouts and such. I haven't provided all of the details here, so go do a web search to find the rest.

          • 2. Re: Any suggestions on adding a new record to a subtable?
            cortical

            The 'pivot' method ( 'magic key') is preferable to change layout/create/record/return, or setting up a multi-predicate key for a dedicated allow creation related record relationship

             

            1. it is faster

            2. it avoids screen flicker under windows

            3. a single g_pivot_id global field can be used for 'all' new related record requirements

            4. no need to calculate a unique left key

            5. it avoids an implicit commit on change layout

             

             

            There is a demo on Nightwing site.

            Also my simple demo attached.

             

            The method is seen by some apparently as one of these SFT ( stupid FileMaker Tricks), and like numerous things just because you can, does not mean you should. But in this case, you should.

            It has been clearly stated, by authorities I certainly trust, that the behaviour that permits the method is not going away any time soon.

             

            I have been using it since a master class last year, and it has been enormously beneficial. Up there with popovers in my book.