5 Replies Latest reply on Feb 15, 2013 11:49 AM by philmodjunk

    efficient check box searching

    ericjlindholm

      Title

      efficient check box searching

      Post

           i have inventory items with multiple checkbox or radio button settings.  The two main ones are:

           "List Visiblity" checkbox options are " Rental, Purchase and Sub rent"

           "Eq or supply" radio button options are " Equipment or Supply"

           "Hide"  radio buttons are options are "Hide as duplicate or out of service"

            

           I have created a global search field for option in a header on my list of invetory and i want it to only display the items with the settings marked in the global fields.  Thanks in advance!

        • 1. Re: efficient check box searching
          philmodjunk

               The radio buttons should not be an issue as they usually are used to only specify one value or the other. but the check box field permits selecting multiple options.

               There are two key questions you need to answer as they alter the find script required to get the results that you want:

               If you select two or more values in List Visibility, do you want only the records that have all of the selected values or all of the records that have at least one of the selected values?

               In the same line of reasoning, if you select a value for Eq or Supply and a value for Hide, do you want only records that have both values or records that have at least one value?

          • 2. Re: efficient check box searching
            ericjlindholm

                 if two or more values are selected, I want records that contain either or both values to be displayed.  as for eq or supply, the seach field is a checkbox while the inventory records are radio buttons.  I would it it to show both if both are checked or just one if one is checked.

            • 3. Re: efficient check box searching
              philmodjunk

                   The two types of searches are sometimes called Exclusive or Inclusive and sometimes are referred to as "And" or "Or" searches. Either you want all the data to match or just any one item needs to match.

                   To script an inclusive search from a global check box field, you can either generate a series of find requests, one for each checkbox value selected and perform a single find, or you perform a find for the first check box value and then use extend found set to find records using each of the additional selected check box values. The results produced are the same.

                   Here's one script it just searches for List Visibility values. See the comments at the end for why I am ignoring the other two fields at this point:

                   Enter Find Mode []
                   Loop
                         Set Variable [$K ; value: $K + 1]
                         Set Field [YourTable::visibility ; GetValue ( YourTable::ListVisibility ; $K ) ]
                         Exit Loop If [$K > valueCount ( YourTable::gListVisibility ) ]
                         New Record/Request
                   End Loop
                   Set Error Capture [on]
                   Perform Find[]

                   When you now specify data in additional global fields, the possible results you want become more complex. Example:

                   If you select "Rental" in the first field and "supply" in the second, do you want an inclusive or exclusive result? All records with Rental OR Supply or only records with Rental and Supply?
                     

              • 4. Re: efficient check box searching
                ericjlindholm

                     I believe it would have to be Rentals AND Supply.

                     Here is my script verbatim and its not working.  Did i miss something?

                Enter Find Mode [ ]

                Loop

                     Set Variable [ $K; Value:$K + 1 ]
                     Set Field [ Inventory::ListVisibility; GetValue ( Inventory::ListVisibility ; $K ) ]

                     Exit Loop If [ $K>ValueCount(Inventory::gListVisibility Search) ]
                     New Record/Request

                End Loop
                                    Set Error Capture
                [ On ]

                Perform Find [ ]

                      

                • 5. Re: efficient check box searching
                  philmodjunk
                       

                  Set Field[ Inventory::ListVisibility; GetValue ( Inventory::ListVisibility ; $K ) ]

                  is the problem. You can't use the same field on both sides of the semi colon. The second one has to be your global check box field and the first one has to be the data field in your table into which you are setting the data from the global for use as search criteria.

                  Set Field[ Inventory::ListVisibility; GetValue ( gListVisibility Search ; $K ) ]

                       That was due to my typo in the example script.

                       Modifying it to include the second search field:

                  Enter Find Mode[ ]

                  Loop

                       Set Variable[ $K; Value:$K + 1 ]
                       Set Field[ Inventory::ListVisibility; GetValue ( Inventory::gListVisibility Search; $K ) ]
                       Set Field[ Inventory::eq or supply; Inventory::gEq or Supply Search; $K ) ]    

                      Exit Loop If[ $K>ValueCount(Inventory::gListVisibility Search) ]
                       New Record/Request

                  End Loop
                                      Set Error Capture
                  [ On ]

                  Perform Find[ ]

                                      Note that this only sets a single value from the gEq or Supply Search field. For multiple values you can easily end up with loops inside a loop and sometimes a Duplcate Record/Request step can simplify the script a bit. The key it to put criteria that makes up an "AND" search inside a single request and criteria that makes up an "OR" search in separate find requests.