5 Replies Latest reply on May 4, 2016 4:55 AM by user19752

    Portal Button to sort based on portal field

    Ben_B94

      Hello,

       

       

      I have a layout sorted by a sub-summary displaying a single portal, the portal contains the fields, name ; job title ; date. How can I get it so that when my layout is sorted and you say press a button in the portal, it will get that persons name and display only their records on the layout.

       

       

      I have tried putting a button in the portal, setting a variable $currentPerson = getfield ( name ). If the button is in the same row as the name does filemaker know to get the name from the name field of the current  portal row? And if not how do I tell it to? Or is there a simpler way.

       

       

      Thanks

        • 1. Re: Portal Button to sort based on portal field
          erolst

          Assuming this is a parent (person) - child (layout table) relationship, you don't need a portal to display the name or other fields from the parent; fields from a related table (outside a portal) always come from the first related record, which is fine if there is only one.

           

          Just put a button into the sub-summary part with

           

          Find Matching Records [ TheLayoutTable::foreignKeyForPerson ; replace ]

           

          Ben_B94 wrote:

          If the button is in the same row as the name does filemaker know to get the name from the name field of the current portal row?

           

          A given reference is resolved using the current context; i.e. Parent::id has different values in different child records, and again on a layout based on parent itself. FileMaker knows how to find 'it', if you tell it where to look.

          • 2. Re: Portal Button to sort based on portal field
            Ben_B94

            Hi Erolst, I have a button with find matching records, but it seems that is it remembering the last search if that makes sense. Press the button and it will work the first time. Every time after it then always goes back to the results of the first search. I tried adding a layout on exit script to show all records, but still gives the same results.

            • 3. Re: Portal Button to sort based on portal field
              Ben_B94

              Ok its doing something else now.  I press the button beside the record, it goes to a 2nd layout and finds matching records based on ID then on that layout it will have an active record selected. Go back to the first layout and search again with a different record and it will always find the previous active record from the 2nd layout.

              • 5. Re: Portal Button to sort based on portal field
                user19752

                $currentPerson = getfield ( name )

                is not correct usage. This use content of name field as field name to get its value.

                 

                $currentPerson = name

                get the name field contents.

                 

                If you use the function to get field contents,

                $currentPerson = getfield ( "name" )

                 

                In some context you need table name prefixed as "table::name"