11 Replies Latest reply on Sep 1, 2014 9:05 AM by jjfcpa

    Portal Filter

    jjfcpa

      Sorry for what may be a very basic question, but I'm struggling with this one. I may be including verbose details, but this is for my benefit as much as for yours, since I'm new to Filemaker.

       

      I have just two tables:

       

      Applications - list of applications we develop

      User Requests - list of requests for program enhancements or changes ( Note, contains a field called PRIORITY and PORTAL_FILTER )

       

      I have an Application listing and from there the user can navigate to a Manage Applications screen that contains a portal listing all the user requests. So I have a 1 to many relationsship from Applications to User Requests based on a parent and child key.

       

      The user requests table contains a field named "priority" and I want to be able to filter the portal on the Manage Applications screen by based on ALL (show all requests) or the priority. The priority is very simple and is based on just 3 selections from a value list of "High", "Medium", "Low".

       

      Here is what I surmised based on forums searches and readings. I thought it would be pretty simple, but can't get the portal filtered.

       

      1. Add a global field ( Portal_Filter) to the User Requests table and set it to ALL on application startup.

      2. In the portal setup, add a filter that says USER_REQUESTS::PRIORITY_FILTER = "ALL" OR USER_REQUESTS::PRIORITY_FILTER = USER_REQUESTS::PRIORITY

      3. I then put a popup field on the layout for the PORTAL_FILTER field with a new value list that has the same priorities as the one for the priority field but also includes ALL.

      4. So if they change the PORTAL_FILTER popup from ALL to say MEDIUM, I'm guessing I need to do something to make the portal filter the contents? This is where I don't be able to get anything to happen except for the PORTAL_FILTER global field changing.

       

      Am I on the right track or do I need to approach this differenty.

        • 1. Re: Portal Filter
          dsvail

          you'll need the portal to "refresh" .  You can do this by putting a OnObjectModify scripttrigger on the global field.

          Script:

          Goto Portal Row (Requests) First

          Set Field RequestID to RequestID // set one of the field values of the row to itself

          Commit Records

          • 2. Re: Portal Filter
            erolst

            I think this is merely a refresh issue.

             

            Use a script as OnExit (or Modify, or Save …) trigger for your filter field and reset the key you use in the relationship to itself (that's “cheaper” than the “Refresh” step).

             

            dsvail wrote:

            Set Field RequestID to RequestID // set one of the field values of the row to itself

             

            That could be problematic if the portal is currently empty as the result of a filter. It's more reliable (and takes less steps) to set the key on the parent side.

            • 3. Re: Portal Filter
              jjfcpa

              This is what I put in the portal's "Set Filter"

               

              User_Requests::RequestPriority = User_Requests::Portal_Filter or User_Requests::Portal_Filter = "ALL"

               

              Recall that when the solution starts up, the USER_REQUESTS::PORTAL_FILTER is to all ALL

               

              Does that look correct?

               

              Just tested and nothing really changes.

               

              Verified that the global field (USER_REQUESTS::PORTAL_FILTER) is getting changed and the script trigger is as follows for the popup which fires on the "onmodify":

               

              Go to Portal Row [Select, First]

               

              Highlights the first row in the portal, but does not filter.

              • 4. Re: Portal Filter
                dsvail

                thanks erolst

                • 5. Re: Portal Filter
                  erolst

                  Both replies have stated that this is a refresh issue – which translates into “your code is correct and works, you just have to give the system a kick in the behind to update the display".

                   

                  And that is what the suggested methods do.

                  • 6. Re: Portal Filter
                    jjfcpa

                    I'm guessing it's a refresh issue, but can't figure out why it isn't refreshing.

                     

                    Even if I change the global field and then go back to the portal, it's like it is ignorning the "set filter" instruction because it still doesn't filter the portal. 

                    • 7. Re: Portal Filter
                      erolst

                      jjfcpa wrote:

                       

                      Go to Portal Row [Select, First]

                      Highlights the first row in the portal, but does not filter.

                       

                      That's hardly surprising; Go to Portal Row [] by itself doesn't do anything, especially not filter (and, as stated, is not really necessary).

                       

                      You need to do something that re-triggers the relationship and causes the portal filter to be re-evaluated :

                       

                      Set Field [ User_Requests::parentPrimaryKey ; User_Requests::parentPrimaryKey ]

                      Commit Records/Requests

                      • 8. Re: Portal Filter
                        jjfcpa

                        If that's true, then why isn't that when I just edit the layout and then exit the layout it still does not refresh the filter?  Is that normal? 

                         

                        I'll try the "set field" command and see if that works.

                        • 9. Re: Portal Filter
                          jjfcpa

                          Works!  Thank you for your help.  Starting to grasp what's going on. 

                           

                          I added the "set field" and a "commit record" and everything started refreshing properly.  Whew.  Didn't think it would take that much to get the filter moving.

                          • 10. Re: Portal Filter
                            erolst


                            jjfcpa wrote:

                            If that's true, then why isn't that when I just edit the layout and then exit the layout it still does not refresh the filter?  Is that normal?

                             

                            Yes. The relationship is cached, and moving back and fro between modes doesn't change the cache. You have to either ditch it completely (which affects all relationships), or do it a bit more targeted (do something that affects only the relationship in question).

                            • 11. Re: Portal Filter
                              jjfcpa

                              Thank you for your insight and assistance.  Definitely made this a more enjoyable Labor Day.  I hope yours is good as well.