7 Replies Latest reply on Jun 25, 2012 6:36 AM by MattLeach

    Search box to filter portal

    MattLeach

      I have a portal setup on a layout that acts as a rolodex, listing all of the contacts in the database.

       

      My client would like something similar to the search field in the finder on the MAC. Basically have a field that they can enter in a client's last name and have the portal show only those matched by the search field.

       

      Is such a thing possible? Thanks

        • 1. Re: Search box to filter portal
          Mike_Mitchell

          Matt -

           

          Couple of different ways to do this.

           

          1) If you want to stick with the portal, you can have the relationship based on the global field in addition to any existing match criteria. (Key field >--< key field AND global field >--< last name). Now, you might ask, "What if the global field is empty? That'll return nothing!" Right you are. To cover such a case, what you can do is, instead of matching on the global field directly, make a calculation field that points to another calculation field in the target table. The calc field on the parent side says:

           

          Case ( IsEmpty ( globalField ) ; "All" ; globalField )

           

          On the child side, it says:

           

          LastName & "<cr>" & "All" (where <cr> is the pilcrow)

           

          Now, if the person leaves the search field blank, your parent side reads, "All". That will match on LastNameCalc fields that look like this:

           

          Mitchell     Leach

          All             All

           

          Make sense?

           

          2) The other option is to convert it to a list view and use the global as a search field. Perform a Find on a script trigger basis.

           

          Whichever suits your situation better.

           

          HTH

           

          Mike

          • 2. Re: Search box to filter portal
            MattLeach

            I would definately like to keep the portal so looks like i'll be giving option 1 a try. Bascially the way the layout is designed is the portal is on the left side and the client information is on the right. Rather than doing a search, the client simply clicks on the client name in the portal and the record is loaded.

             

            Currently i have the relationship setup with a cartesian join Clients::Rolodex_Name > x < Clients::Rolodex_Name

             

            The Rolodex_Name field is a calculation that joins the first and last name (last, first)

             

            So based on the information you provided above, i would have to create a search field (we'll call is search), make it global, then add another step to the relationship so it would look like:

             

                      Clients::Rolodex_Name X Clients::Rolodex_Name

            AND   Clients::Search = Clients::Rolodex_Name

             

            I'll be honest, you kind of lost me on matching the global field to a calc.

             

            Thanks

            Matt

            • 3. Re: Search box to filter portal
              Mike_Mitchell

              Sorry. I'll try again.

               

              The calc is necessary because you want to show all the records in the portal even if the search field is empty. If you just do it directly, then if Clients::Search is empty, your portal will return no records. That's, well, bad.

               

              Therefore, you want to be able to equate an empty Clients::Search with ALL records in Clients::Rolodex_Name. How to do that? Well, you have to substitute something in the relationship on the left side that will match all records on the right side. So, you have two choices:

               

              1) The calc on the left is set to be all records. UGLY.

              2) The calc on the left is set to some sort of constant, which you then add to each record on the right side.

               

              The latter is what I would do. So, on the left side you set the match calc to:

               

              Case ( IsEmpty ( Clients::Search ) ; "All" ; Clients::Search )

               

              On the right, you have a new field, "Rolodex_Name_Match". This calculation is equal to:

               

              Clients::Rolodex_Name & "<cr>All"

               

              This would produce something like:

               

              Leach, Matt

              All

               

              in the calculated field. Then set the relationship to be equal to Clients::SearchCalc = Clients::Rolodex_Name_Match as the second predicate.

               

              In this way, if the person types, "Leach, Matt" OR nothing at all, it will still match.

               

              If this still isn't making sense, let me know and I'll slam a demo together.

               

              Mike

              • 4. Re: Search box to filter portal
                MattLeach

                I've attempted what you have outlined but the portal stays empty whether the field contains a name or is blank.

                 

                I've attached a copy of the file, perhaps i may have done something incorrect.

                • 5. Re: Search box to filter portal
                  davehob

                  Matt,

                   

                  I had to do such a thing, and used the technique that I've described here

                   

                  It's broadly similar to the solution Mike's described, but may give you another variation to choose from.  It seems to work well, and is nice and fast.

                   

                  Regards,

                   

                  Dave.

                  • 6. Re: Search box to filter portal
                    Mike_Mitchell

                    Matt -

                     

                    I don't see in your relationship graph where you've added a predicate for the global. In fact, I don't even see a global field at all in the Clients table. I'm assuming you meant for Rolodex_Filter to be the global. With that in mind, I modified your copy to do what you want.

                     

                    HTH

                     

                    Mike

                    • 7. Re: Search box to filter portal
                      MattLeach

                      My apologies Mike, i just realized i uploaded the wrong copy of the file which was just before i made the changes you suggested.

                       

                      Thank you very much for taking the time to look at the file, it is greatly appreciated.