6 Replies Latest reply on Nov 1, 2011 9:01 AM by philmodjunk

    Global Search



      Global Search



      I have a complicated issue:

      using the quick find in FM I want to display the results of the research as multilines in a grid (like Google).

      Is the reports can help me here to display the results?

      thanks for the hints

        • 1. Re: Global Search

          Whether performing a find or a quick find, with scripting, you can display the resulting found set of records in a list or view where individual records can then be clicked to bring up a form view layout of the selected record if you do so via scripting rather than manually.

          Define a text field with global Storage: gSearchText

          Run this script:

          Perform Quick Find [ YourTable::gSearchText ]
          If [ Get ( FoundCount ) > 1 //multiple records were found ]
             Go To Layout ["List View"]
             #Do nothing or.:
             Go to Layout ["Form View"]
          End If

          "List View" and "Form View" would be layouts based on the same table that you are searching, but you configure one layout to support a list view of all your found records and the other is configured for Form View where you gert a detailed view of the selected record. On the list view layout, you can either use Button Setup... to change all the fields in your list view into a single button or you can add a button to the body of the layout that perform this single script step:

          Go To Layout ["Form View"]

          And then you can select a record for viewing/editing from your list of found records with a single mouse click.

          • 2. Re: Global Search


            I'm confused by quick find results:

            I created a list view layout and I put a field "GlobalSearch" on the header. my main idea is to have a search field (as google) on the same page as the result, and when no resul found it shouldn't list any records.

            So When I click on search button that i created I run this script 'see attach).

            the pbm is the first time i run the script Get ( FoundCount ) return good result (e.g: 1 if i have one record)

            the second time if I should not have a record found, the Get ( FoundCount ) retrun also 1 (cause the old retrieve is =1), therefore i have the old result displayed!

            how can i reset the display in the list if i don't have any record as result in my current quick find?

            hope i was clear

            thx in advance



            • 3. Re: Global Search

              in fact i run the debugger and i saw that when the second time the system execute the Perform Quick Find[$$globalsearch] immediately the result (one record) is displayed on the screen, so of course the foundcount will retrieve 1 record.

              so the issue why the Perform Quick Find[$$globalsearch] is returning an old value as result, although i checked the variable $$globalsearch, it takes the new value.

              • 4. Re: Global Search

                Why do you enter find mode after the custom dialog box pops up to say "no result found"?

                It appears that the found set is not changed if no records are found--unlike a standard scripted find with set errror capture enabled.

                Try this code instead:

                Perform Quick Find [ YourTable::gSearchText ]
                If [Get ( LastError ) > 0 // no records found]
                   #Use next to steps to create empty found set only if you want to...
                   Show All Records
                   Show Omitted only
                   Show Custom dialog ["no records match this criteria..."]
                Else If [ Get ( FoundCount ) > 1 //multiple records were found ]
                   Go To Layout ["List View"]
                   #Do nothing or.:
                   Go to Layout ["Form View"]
                End If

                • 5. Re: Global Search

                  no infortunaltely it doesn't work.


                  I used Get ( LastError ), it retrun 0 after the Perform Quick Find while i should have not zero, cause i'm searching something that doesn't exist in the database.


                    >>Why do you enter find mode after the custom dialog box pops up to say "no result found"?

                  I'm using this to clean the page from the previous result; that is my main problem.

                  fot that reason also, i trigger on page load the script : enter find mode on order to clean the page and it works. but the pbm is whenever i perform quick find ($$globalsearch) statement with a value that doesn't exist, the page return 1 record, also the same record !

                  i don't know if i'm doing right :(

                  • 6. Re: Global Search

                    I don't recommend entering find mode for this purpose. Instead, manipulate the found set to produce zero records.

                    Here are two options for that:

                    Show All Records
                    Show Omitted only

                    Enter Find mode[]
                    Set Field [YourTable::SomeField ; "ImpossibleValue"]
                    Set Error capture [on]
                    Perform FInd[]

                    The first option is simplest but can fail in shared databases where one user might create a new record at the same time this script executes and that can pop up that new record when you don't want it to. The second option requires specifying search criteria guaranteed to not to match any record. I usually search for a negative number in an auto-entered serial number to do this.

                    I just ran a quick test and that tells me you need to doublecheck your script.

                    When I run this script:

                    Perform Quick Find ["xxxxxxxxx"]
                    Show Custom Dialog [ Get ( LastError )]

                    I get both the same dialog "no records match..." that I do with performing a standard find and the same error code: 401 is returned.

                    You may want to post your script here if you'd like others to see if they can spot what's not quite right in your script:

                    To post a script to the forum:

                    1. You can upload a screen shot of your script
                    2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
                    3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
                    4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional look to your script. (Use the HTML option and paste the text into the HTML editor.)