7 Replies Latest reply on Apr 6, 2016 6:36 PM by Vaughan

    Making searches OR instead of AND

    douglerner

      If I have a bunch of checkboxes, and I do a search and select several of them, I notice the resulting search results are an AND of the selected checkboxes.

       

      Is there a way of changing that behavior so the search results are an OR of the selected checkboxes?

       

      Thanks,

       

      doug

        • 1. Re: Making searches OR instead of AND
          erolst

          Create one request per checkbox (in Find mode, cmd/ctrl-N creates a new request, rather than a new record).

           

          Search criteria within a request are ANDed, the requests themselves are ORed.

          • 2. Re: Making searches OR instead of AND
            douglerner

            Nothing less tedious than that? Suppose there are 50 checkboxes and we want to OR 8 of them. We have to repeat that 8 times to achieve a final result?

             

            Thanks,

             

            doug

            • 3. Re: Making searches OR instead of AND
              ninja

              ...or script it...

               

              Enter Find mode

              SetField(CheckBox ; "Yes")

              New Record/Request

              SetField(CheckBox ; "No")

              New Record/Request

              SetField(CheckBox ; "Maybe")

              New Record/Request

              SetField(CheckBox ; "Sort Of")

              New Record/Request

              SetField(CheckBox ; "not really")

              Perform Find

              • 4. Re: Making searches OR instead of AND
                erolst

                douglerner wrote:

                Nothing less tedious than that? Suppose there are 50 checkboxes and we want to OR 8 of them. We have to repeat that 8 times to achieve a final result?

                 

                I assume you mean “there is a field formatted as checkbox with a value list of 50 items”?

                 

                Since you can always write a script to automate processes, and because a checkbox formatted field is just a return-delimited list of values, you can simply do this:

                 

                If [ Get ( WindowMode ) ≠ 1 ]

                  Enter Find Mode

                  Exit Script

                End If

                Set Variable [ $searchList ; YourTable::yourCheckBoxField ]

                If [ isEmpty ( $searchList ) ]

                  Enter Browse Mode

                  Exit Script

                End If

                Loop

                  Set Field [ YourTable::yourCheckBoxField ; GetValue ( $searchList ; Get ( RequestCount ) ) ]

                  Exit Loop if [ Get ( RequestCount ) = ValueCount ( $searchList ) ]

                  New Record/Request

                End Loop

                Perform Find

                • 5. Re: Making searches OR instead of AND
                  Mike_Mitchell

                  erolst's answer will script just fine. Another way to do it is to create a new TO (table occurrence) and join the checkbox field to itself. (Commonly referred to as a "self join".) This gives you the ability to do a simple Go to Related Record script step to isolate the records that match the checkbox set.

                  • 6. Re: Making searches OR instead of AND
                    douglerner

                    Thank you all for the information. I understand now.

                     

                    I have to admit I'm a bit surprised though that there is no out-of-the-box way of just saying "I want this search to be an OR of all my selections".

                     

                    Thanks,

                     

                    doug

                    • 7. Re: Making searches OR instead of AND
                      Vaughan

                      douglerner wrote:

                       

                      Thank you all for the information. I understand now.

                       

                      I have to admit I'm a bit surprised though that there is no out-of-the-box way of just saying "I want this search to be an OR of all my selections".

                       

                      Thanks,

                       

                      doug

                       

                       

                      That's partly because checkboxes break first normal form: there is more than one value stored in the field.