4 Replies Latest reply on Mar 14, 2016 4:04 AM by cillion

    Search portal for 2 fields containing the search word, and one dropdown

    cillion

      Hi out there!

      Im stuck trying to make a search field, that is going to show portal rows that containing the search value, so if it find the value in one of those two field the row will show. The dropdown will be addon filter for the search field, to narrow the search futher down on a third field. I will appreciate all the help I can get

       

      This is my setup now, I know am on to something but not quite there yet:

      The layout looks like this, the Company field is going to search on and show find in either Current Company or Previus Company

       

      2016-03-10_19-14-24.png

      The Find_People table have I made like this:

      2016-03-10_19-20-04.png

       

      And the relationship between the tables like this.

      2016-03-10_19-20-46.png

        • 1. Re: Search portal for 2 fields containing the search word, and one dropdown
          DanielShanahan

          You could use a portal filter like this:

           

          Case (

            IsEmpty ( GLOBAL::Company_g ) ; 1 ;

            PatternCount ( PERSON::Current Company ; GLOBAL::Company_g ) or

            PatternCount ( PERSON::Previous Company ; GLOBAL::Company_g )

          )

           

          See if the attached is helpful.

          • 2. Re: Search portal for 2 fields containing the search word, and one dropdown
            cillion

            This is very interesting Daniel So do that mean that if I have a new search field(dropdown) to compare to a countryID for example, then I just need to add a new patternCount in the case?

             

            Why have you used X in the relationship and now = ?

             

            What is the different between having the case in a own calculation field as I did, than a portal filter like you?

             

            And do all the field am searching for be indexed?

            • 3. Re: Search portal for 2 fields containing the search word, and one dropdown
              DanielShanahan

              So do that mean that if I have a new search field(dropdown) to compare to a countryID for example, then I just need to add a new patternCount in the case?

              Adding another search criteria makes the filter more complex.  This is how I do it in the attached:

               

              Case (

                  // ------- DISPLAY ALL

                  IsEmpty ( GLOBAL::Company_g ) and

                  IsEmpty ( GLOBAL::Country_g ) ;

                  1 ;

               

                  // ------- DISPLAY COUNTRY

                  IsEmpty ( GLOBAL::Company_g ) ;

                  PatternCount ( PERSON::Country ; GLOBAL::Country_g ) ;

               

                  // ------- DISPLAY CURRENT AND PREVIOUS COMPANIES

                  IsEmpty ( GLOBAL::Country_g ) ;

                  PatternCount ( PERSON::Current Company ; GLOBAL::Company_g ) or

                  PatternCount ( PERSON::Previous Company ; GLOBAL::Company_g ) ;

               

                  // ------- DISPLAY COUNTRY AND CURRENT AND PREVIOUS COMPANIES

                  PatternCount ( PERSON::Country ; GLOBAL::Country_g ) and

                  ( PatternCount ( PERSON::Current Company ; GLOBAL::Company_g ) or

                  PatternCount ( PERSON::Previous Company ; GLOBAL::Company_g ) )

              )

               

              It should also be noted that you could do this with table occurrences in the relationship graph.  But in this case, I'm filtering the data based on the portal filter.

               

              Why have you used X in the relationship and now = ?

               

              The "X" is a Cartesian join.  In this case, it means the portal will show all the records from the PERSON table.

               

              What is the different between having the case in a own calculation field as I did, than a portal filter like you?

              A field calculation by itself will not filter the portal.  There are two ways to filter the portal:

              1. With the "Filter portal records" in the Portal Setup dialog box (double click the portal to get the dialog box).

              2. Using  a relationship between table occurrences.

               

              For what its worth, while field calculations can be powerful, many developers try to restrict it to calculations that can be indexed (like concatenating a first and last name, for example).  Unstored field calculations can bog down a data system so it is generally a good idea to move this logic to a script.

               

              And do all the field am searching for be indexed?

              That is a great question.  The fields do not need to be indexed for the portal filter.

               

              See the new attached file for an updated filter.

               

              Hope that helps.

              • 4. Re: Search portal for 2 fields containing the search word, and one dropdown
                cillion

                Nice, great information and work making me understand So in the future, what should I change in the filter calculation to add even one more field for search?