9 Replies Latest reply on Dec 14, 2013 5:20 PM by erolst

    How to create a field to search for records?

    hafiz5198

      Hi there again!

      How do I create a search box to search for records?
      E.g. I created a table and some fields that stores profile of people and I want to search for someone maybe by entering their name or age or something else.

      Teach me the easiest way.

        • 1. Re: How to create a field to search for records?
          erolst

          hafiz5198 wrote:

          Teach me the easiest way.

           

          Shouldn't that be

           

          Set Variable [ $askForHelp ; "Teach me the easiest way, " & $$theMagicWord ]

          1 of 1 people found this helpful
          • 2. Re: How to create a field to search for records?
            TimAnderson

            Or you could use this

             

            http://www.seedcode.com/fm-search-results/

             

            Very fast, flexible and easy to integrate

            • 3. Re: How to create a field to search for records?
              cortical

              it depends on whether you want the search result listed in a portal, or are working on a table layout

               

              For a portal result the simple 'traditional' way

              create 2 fields for the left side of the REL:

              g_search ( text global)

              c_search = g_search & "zzz"

               

              The right side of the REL, can be an auto entercalc, a simple example:

              aec_names_keywords = first_name & "¶" &   last_name

              numerous variations, add other fields, substitute spaces with pilcrows...

               

              create a dual predicate REL

              g_search ≤ aec_names_keywords

              c_search ≥ aec_names_keywords

               

              put g_search on the search layout, with the portal. Additioanal finessing can be added to get keystroke result refresh using appropriate script triggers

               

               

              Alternately for a search global on a table ( or list) layout

              a global ( g_search) and a script trigger (OOM) and script to execute a find, refreshed on keystroke. This may/will need additional consideration/finessing on iOS ( to avoid flicker) and large record sets

              basically parse the search string to $_search

              enter find mode

              set target field ( e.g. aec_keywords) to $_search

              perform find

              go object ( global search field) // i.e. to renter the cursr into the seacrh global

               


               


              • 4. Re: How to create a field to search for records?
                vavo

                Hi,

                 

                the easiest way for you might be using quick find:

                 

                1. Create a text field with global storage (i. e. g_search).

                2. Write a script:

                 

                If [ code ( get (triggerKeystroke) ) = 13 ]

                     Perform Quick Find [g_search]

                End If

                 

                3. Set a script Trigger for g_search onObejctKeystroke with the script above.

                 

                This will trigger a search when you hit the return key in the search field and searches all fields on the layout (not in the table). It does the same as the search box provided in Filemaker. it gives you a lot less control on what to search on but it is easy.

                1 of 1 people found this helpful
                • 5. Re: How to create a field to search for records?
                  erolst

                  cortical wrote:

                  basically parse the search string to $_search

                   

                  Why, when you already have the value in a global?

                  • 6. Re: How to create a field to search for records?
                    cortical

                    declaring variables and parsing values at the start of scripts is just good coding practice

                    it also means the same $_var can be used multiple times within a script, and the initial source could be changed, conditional switching added/whatever as more calls are intergated/the script gets more sophisticated,  on the initial declaration.

                    • 7. Re: How to create a field to search for records?
                      erolst

                      cortical wrote:

                       

                      declaring variables and parsing values at the start of scripts is just good coding practice

                       

                      Not much “parsing” that I can see …

                       

                      You're right in spirit, but for a 3- or 4-liner with one use of the exact same value, I save myself the effort. If and when the script becomes longer and/or more complicated, or if you want to assign a more complex staement to a variable, you can start creating centralized and easily re-definable variable assignments (as in “re-factoring” – another coding practice …). Even good rules don't have to be followed slavishly.

                       

                      But thanks for the lecture about “good coding practice” anyway …

                      • 8. Re: How to create a field to search for records?
                        cortical

                        bit short for a lecture

                         

                        consistency is also worthwhile, good habits and all that, PLUS the original poster is presumably still reading each response

                        • 9. Re: How to create a field to search for records?
                          erolst

                          cortical wrote:

                           

                          bit short for a lecture

                           

                          Yes, that too  … and of course I deeply care about the OP. Maybe she/he even bothers to respond, who knows …