1 Reply Latest reply on Jul 30, 2015 4:16 PM by philmodjunk

    Can join-table portal add to join AND distant related table at once?



      Can join-table portal add to join AND distant related table at once?


      I have a many to many relationship set up with correct key fields: Books::   jBooks_Tags::   Tags::

      The portal on Books:: layout is based on jBooks_Tags and lets me add records. I can also select the Tag from a popup menu. But, I want it to add a new Tag from there, as well, if it doesn't already exist.

      Is this possible? If so, can someone give me a hint?

        • 1. Re: Can join-table portal add to join AND distant related table at once?

          I prefer to add a button near the portal for adding a new record "on the far side" of the join table. It can do something like this to add a new record to Tags:

          Set Variable [$BookID ; value: __pkBookID ]
          Go to layout ["Tags" (Tags) ]
          New Record/Request
          Set Variable [$TagID ; value: __pkTagID ]
          Go to Layout ["jBooks_Tags" (jBooks_Tags) ]
          New Record/Request
          Set Field [jBooks_Tags::_fkBookID ; $BookID ]
          Set Field [jBooks_Tags::_fkTagID ; $TagID ]
          Go To Layout [Original Layout ]

          If the only other field to fill out for the new record is the text field with the tag text, and you then have that field in your portal row, you'd complete the operation by entering this text into the field of the new portal row that this script caused to appear in your portal. In other variations of this method, you can open a custom dialog, a new window, a popover, or just pause on the tags layout in order for the user to complete the data for the new record. The popover makes a very slick option for this. You can even set up the popover with a two pane slide control where panel 1 is a selection portal for finding and selecting a tag while panel 2 is a "new tag" panel with appropriate fields and scripting.

          It is also possible to add what I call "action values" to your pop up menu of tags. These appear above a single value divider line and a script that is performed when you select a value from the list checks for an action value and does the action (create and link in a new tag record) if that was what the user selected.

          For examples of field based value lists that include action values and examples of selection portals located inside popovers, see:

          "Adventures in FileMaking #2 - Enhanced Value Selection"