7 Replies Latest reply on Feb 8, 2015 1:35 PM by disabled_jackrodgers

    Trying to have active/focused Portal row set a global field - without added buttons

    stevegleason

      I apologize for the semi-newbie question.

       

      I'm using Filemaker 13 Advanced.

       

      I have a solution that works, but it seems rather inelegant.

       

      For a time tracking solution, I have a table for all employees. On each employee's record, there is a portal listing related work days (shifts). If I select an individual shift, an additional portal will list the shift detail, all of the assignments that the employee billed time to for that day.

       

      (So effectively, I have the same thing as a Clients > Invoices > Invoice Line Item Detail relationship).

       

      In order to have the shift detail portal display related records, I have the date field in the shifts portal set as a button to activate a script that sets a global variable with the selected shift. That works fine. I have some conditional formatting that helps keep the focus on that selected shift portal row, too. But this feels kludgy. I am going to need to repeat this type of filtering throughout my solution. And I would like to do it with the leanest design that I can.

       

      What I would prefer is if the "active row state" on the shifts portal would set the global variable. I have tried setting the whole portal row as a button, but doesn't let me select an individual portal row, it just takes the value from whichever value is in the first row of the portal.

       

      I would think that defining related portals by a "key" field in an active/focused portal row would be a fairly common ask. (My next beef is the need to use hacks in order to have dynamically sorted portal row headers - again, I feel that this would be a common usage for portals as "lists within layouts" - where you could designate header rows as sort keys. And in an idealized version, you could select multiple sort keys, designating the order and direction (ascending/descending).


      I would appreciate any suggestions.

       

      Thanks

        • 1. Re: Trying to have active/focused Portal row set a global field - without added buttons
          flybynight

          An OnObjectEnter script trigger with a Set Field script step should do the the trick.

          You may need to add a Refresh Object step to get your target detail portal to update.

          The old way to refresh was to use Refresh Window with Flush Joined Cache Results, but that has some performance issues. Refresh Object is much more targeted. Or you can research the "Cartesian Refresh" technique… but that is a little more to wrap your head around.

           

          HTH,

          -Shawn

          1 of 1 people found this helpful
          • 2. Re: Trying to have active/focused Portal row set a global field - without added buttons
            stevegleason

            Hi Shawn,

             

            Thank you for the help! That worked as you said that it would.

             

            One thing that would be nice is if the original (list) portal could retain its focus, with the highlight on the selected portal row, once I click on a row. I have a workaround now, where I use conditional formatting to change the field background if the row's shift matches the selected global shift. But it would be easier to implement, solution-wide, if I could skip to conditional formatting and simply use the portal row focus.

             

            Would you have any insight there?

             

            Thanks again.

            • 3. Re: Trying to have active/focused Portal row set a global field - without added buttons
              flybynight

              I re-checked what I had done for one of my solutions…

              Mine was a little different. My layout is based on the Brand table, with a portal based on the Models table. Then I have a join table for Models_Vendors, as some products are available from more than 1 vendor.

               

              When a user selects a Model from the portal, my script trigger sets a $$variable. Then, I have a conditional formated circle in the Models portal rows that turns green when that ID = $$variable.

               

              Below that, the Models_Vendors portal is filtered to the same formula as the conditional formatting of the circle.

               

              As for actually keeping the focus, I don't think there is a way to have more than one item "in focus" - so once I go down to my Models_Vendor portal, I lose the focus of the Models portal row… but my "marked" circle stays green in that row.

               

              Maybe someone else has another solution, but this works for me.

               

              Laters,

              -Shawn

              1 of 1 people found this helpful
              • 4. Re: Trying to have active/focused Portal row set a global field - without added buttons
                stevegleason

                Hi Shawn,

                 

                I had done the same thing that you did. When the ID matched the variable, it triggered a conditional formatting.

                 

                I figured out how to do what I wanted to do.

                 

                1. Store the current portal row in a global field

                2. Set the variable for the selected shift (or job #, or whatever my starting point is) as a variable, which prompts the detail to display in the second portal

                3. Go back to the first portal (which has to be made a named object in layout mode first)

                4. Go to the saved portal row

                 

                To the user, this makes it look like the active portal row never lost focus.

                 

                Initially, I had a commit record step after step 2, and that got the script stuck in a loop (that I could escape from). Deleting that commit record step made the script work as expected.

                 

                Screen Shot 2014-01-15 at 12.29.12 PM.png

                 

                So now I can click anywhere in a row of a list portal, my matching detail will show in the second portal, and the focus will remain in the first.

                 

                The conditional formatting method that both you and I have used works fine. But I prefer this one, in order to easily highlight the entire row.

                 

                I still wish that this was a default behavior, but it wasn't too difficult after all.

                 

                I truly appreciate your help.

                 

                Steve

                • 5. Re: Trying to have active/focused Portal row set a global field - without added buttons
                  flybynight

                  Steve,

                   

                  Glad it's working for you. I guess I'm not sure if I was totally understanding you regarding the focus. In my solution, the method I outlined does keep the focus on the portal row after you click on it. Screen shot here:

                  Screen shot 2014-01-15 at 2.13.12 PM.png

                  When you click outside of the portal, or in the bottom portal, the top portal does lose its focus (the darkened row). But, my green dot does stay there (conditional format of portal table ID = $$variable), and the bottom portal does stay on the records related to that top portal row's record (portal filter set to vendor item fk = $$variable).

                   

                  I thought you were trying to keep focus on the first portal row, after you clicked into the second portal.

                   

                  I'm actually thinking it may have been your commit script step that was causing it to lose focus. I wonder if deleting that step is what actually "fixed" your issue, and now you might just have some extraneous steps in there. Just for curiousity, I would try deactivating your Set Field for the ActivePortalRowNumber step and your 2 Go To… steps, to see if it still works. I wonder if the Go To… steps were forcing a refresh, so a Refresh Window or Refresh Object script step wasn't necessary?

                   

                  But then again, I've been known to keep tinkering after I get something working… and end up breaking it again! 

                  You may just want to leave what you have, if it's working for you!

                   

                  Laters,

                  -Shawn

                  • 6. Re: Trying to have active/focused Portal row set a global field - without added buttons
                    stevegleason

                    Hi Shawn,

                     

                    Yep. You nailed it. Deleting the commit script step kept the focus.

                     

                    Thanks. The simpler the better.

                     

                    Steve

                    • 7. Re: Trying to have active/focused Portal row set a global field - without added buttons

                      I assume you are using a hierarchical relationship between your portals. Here's one I made that starts with selecting the country which then gives you a listing of the states. Select a state and pick a county. Select a county and pick a city. Click on the city and get the zip code...  )

                       

                      Each column shows nothing until you've clicked on the ones on the left.

                       

                      2014-09-11 16.38.46.png

                      I used conditional formating via a set global to its value and colored it green. Since someone might scroll the portals or click outside of them using conditional formatting saves the values.

                       

                      It might also be of value to show the globals above each portal as I have here so that you don't need to scroll to see what was selected.

                      1 of 1 people found this helpful