1 Reply Latest reply on Jun 5, 2013 9:18 AM by davidanders

    How to create AND and OR search for fields that contains words separated with ','

    phoonyik

      Title

      How to create AND and OR search for fields that contains words separated with ','

      Post

           Hi. 
           I really need help for this filemaker script making issue. Basically, I m given a field that takes in texts and all the keywords in it are separated with commas. 

           Example :    Keywords:   New, Mathematics, Model

           So when the user clicks on the "AND" button, it converts the keywords into New AND Mathematics AND Model and then perform a search based on it. 

           Any ideas? I would really appreciate it :)

        • 1. Re: How to create AND and OR search for fields that contains words separated with ','
          davidanders

               COPIED FROM  Setup Keyword Search

                              It makes things much, much easier.

                              Next question: Why the extra table for entering key words? Do you want to save this criteria for later use?

                              If not, just define a global field for your list of keywords. Put a second global field on this layout for the user to use to select the desired table. You can format this field with a drop down of table or layout names.

                              Your script then follows this basic outline:

                              Use the global field of table names to select the correct layout (you'll need a different layout for each table on which the user might search.) Use either a series of If -Else If statments to select the correct layout or you can use Go To Layout with the "layout name by calculation" option if the global field's value list lists the actual names of the layouts.

                              The rest of your script then does this:

                              Set Variable [$Keywords ; Substitute ( YourTable::gKeywords ; "," ; ¶ ) ]
          Enter Find Mode[]//clear the pause check box
                              Loop
                                 Set Variable [ $I ; $I + 1 ]
                                 SetFieldByName [//Expression that computes Name of Table::Field from user choice in global layout field ; Getvalue ( $Keywords ; $I )]
                                 Exit Loop If [$I > ValueCount ( $Keywords ) ]
                                 New Record/Request
                              End Loop
                              Set Error Capture [on]
                              Perform Find[]

                              This will find all records on the selected table if the record contains keyword 1, or keyword 2 or....

                              If you want the keyword search applied to multiple fields in the same record, define a calculation field in each table defined to combine all the searchable fields into a single concatenated block of text: List ( Field1 ; Field2 ; Field 3; ...) or Field 1 & " " & Field 2 & .... and do your search on this field.

          Edit note: left out script step in Red originally.