8 Replies Latest reply on Dec 20, 2014 11:34 AM by philmodjunk

    Showing related field outside portal

    Jakedeg

      Title

      Showing related field outside portal

      Post

      There must be a simple way to do this, but I can't figure out how to search for it. 

      I have a layout called "Preset Details" showing a record from a table called "Preset List". One of the fields in "Preset List" is a container field with an image of the Preset. 

      There is a related table called "Preset Contents" because each preset contains many Channels and the channels are in this table. Each channel also has an image. The list of related channels is displayed in a portal on the "Preset Details" layout.

      I am trying to figure out how to set it up so that by default, the layout shows the "Preset Image" container field and displays the image but then if I click into the portal and select a portal row, the "Channel Image" container field from the "Preset Contents" table replaces the Preset Image. 

      I was imagining I'd put the "Channel Image" field on top of the "Preset Image" field in the layout and use a hiding condition so it only shows when a portal row is active, but that seems to need a refresh window command to update. Plus, I can't even figure out how to get a field that isn't in the portal to be based on which portal row is selected. How do I make that work?

        • 1. Re: Showing related field outside portal
          philmodjunk

          Let's say your portal relationship looks like this:

          LayoutTable::_pkID = PortalTable::_fkID

          Add another Tutorial: What are Table Occurrences? of the portal's table and link it in like this:

          PortalTable|SelectedImage::_pkPortalTableID = LayoutTable::_fkSelectedImageID

          Then a script, performed by a button in the portal row or the OnObjectEnter script trigger set on the portal can do this:

          Set Field [LayoutTable::_fkSelectedImageID ; PortalTable::_pkPOrtalTableID ]

          Then add your container field to the layout from PortalTable|SelectedImage.

          • 2. Re: Showing related field outside portal
            Jakedeg

            Awesome. This is working great. Thanks! I got the image to switch when I switch portal rows. Now I'm still trying to figure out what hide condition will work so that the container field will only appear at all when I'm in the portal... Any ideas on that?

            • 3. Re: Showing related field outside portal
              philmodjunk

              Have the same script set the value of a global variable such as $$ContainerVisible to 1.

              Use a "hide object when" expression of: Not $$ContainerVisible

              Use the inspector to give the container field an object name. (enter a name into the Name box).

              After the set variable script step that sets $$ContainerVisible to 1, use Refresh Object to refresh this one layout object on your layout.

              • 4. Re: Showing related field outside portal
                Jakedeg

                Ah ha. The "Refresh Objects" idea alone was the key. Now I have just set the Hide Condition to be Get ( ActivePortalRowNumber )< 1 and as long as my OnEnter script refreshes that object, it works. With the global variable method, it was harder to get the container to go away when I clicked back out of the portal. Thanks!

                • 5. Re: Showing related field outside portal
                  Jakedeg

                  Ok. Still having some lingering issues. I am trying to get a bunch of objects to show up and be related to whatever portal row I'm in, but not be there when I'm not in the portal. The first part is working ok thanks to the refresh script step. But when I leave the portal, the script is not triggered since it's on "On Enter" so none of the objects realize I have left and they are still sitting there visible when they should be hidden. I tried to add an "On Exit" script too, but then navigation inside the portal becomes unbearably slow. Other ideas?

                  • 6. Re: Showing related field outside portal
                    philmodjunk

                    OnObjectExit and OnObjectEnter are triggers that are tripped as you enter and exit the portal row, not the portal as a whole as I recall. So I can see how there could be a "lag" as you move the focus from one portal row to the next as that will trip both triggers as you exit one portal and enter the next.

                    Hmmmm, can't think of any suggestions at this moment...

                    • 7. Re: Showing related field outside portal
                      Jakedeg

                      Thanks for the follow-up. I don't really understand how, but the container image is working correctly is disappearing when I click out of the portal. Everything else, though, isn't. And it all has the same "Get ( ActivePortalRowNumber )< 1" hide condition. I wonder what is different about the container that's making it work...

                      • 8. Re: Showing related field outside portal
                        philmodjunk

                        Depending on what you click, your "click outside the portal" may be committing records and this can enable things to update even without the Refresh Object step. Clicking the blank area of your layout will commit records. Clicking into another field will not.