SeedCodeCalendarPro

System Wide Quick Search

System-Wide Quick Search

Overview

The search field in the the upper right of SeedCode performs a system-wide search, quickly searching multiple tables at once and presenting the results in a new window. These search results are links that can take you to the individual records found or to entire found sets of records (click on things like "102 Contacts" to go to the found set of contacts instead of an individual contact).

While you may still need to perform traditional finds in order to search for very specific things, this system-wide search is a very fast way to find individual contacts, recent activity, etc. and is probably the fastest way we've found to look for someone's phone number. Best of all, using this search doesn't disturb your existing found sets until you click on a search result; so if you just want to find someone's phone number, you'll see it in your search results' new window, while the layout and found set you were working on is left undisturbed.

Credits

This system-wide search is based on a technique developed by Dr. Matt Navarre (of MSN Media and Pre1 Software) and generously demoed at several FMPug meetings in the summer of 2007. You can reach Matt at http://www.msnmedia.com/

Supported Search Operators'

You can perform some interesting searches in this quick search, though it doesn't support all the operators using in FileMaker's Find Mode. The most useful operator is probably the range operator: "..." Using this you can search for dates like this...

1/1/2007...1/07/2007

And get back not only all the appointments that week, but all the invoices sent week as well. You can't use the less-than or greater-than operators, however.

Using Plugins

We’ve included some code to let the quick search work with the free Zipp Script plugin from http://www.zipptopols.com

If you have this plugin you won’t need to click “search” after you type in your search criteria; simply enter your criteria and click enter on your keyboard and the Zipp Script plugin will fire the search script for you.

Extending this Search

Overview

The quick search follows a script to decide which tables to search and which fields within those tables to search on. The main script is called “Search { Action }” and it calls subscripts for each table being searched and finally calls “Search - Display Results ( Subject )” to write out the actual search results. Most of the behaviors you’ll want to change in this routine can be found in these scripts.

Adding a new field to a table already being searched.

Scripts like “Search Activities” include precise instructions for searching individual fields in each table. This is one reason the search is so useful- we know to search the invoice date in the invoice table and the mailing date in the mailing table when you put a date in the search criteria. You can add a new set of lines to any of these subject specific scripts like “Search Activities” or “Search Contacts” to search on new or different fields. Though you can take this pretty far by patterncounting for things like phone numbers, in general you’ll add a New Record / Request Line and a Set Field line for each new field you’d like to search.

Adding a new table to be searched.

To add a new table to be searched you need to edit several things. This may seem like a long list, but once you get the hand of this, you can extend this routine very easily...

1. You’ll need to create a search layout based on the new table occurrence. Take the layout Search Activities as your example. The layout doesn’t have to have any fields on it except any date fields you wish to search on.

2. Create a subject-specific search script for the table, following the example of the Search Activities script. Note that the date fields being searched on are within the IF() statement.

3. Call your new subject specific script within “Search { Action }” following the format after the “Perform searches in specific tables” comment.

4. Edit the script “Search - Display Results ( Subject )” and find the comment “Actual result display follows”. You’ll need to edit the line before this comment to include your table's primary key in the Case statement, and then edit the _next_ script line so nthe Set Field there includes a section for your new table. Follow the same format as the $Subject = "Contact" section, including all the fields you’d like displayed within the List() statement.

5. In the same script, edit the line above the “Actual result display follows” comment to write out the primary key in your table.

6. Edit the script “Search - Go to Results ( Line )” and add a section for your new table following the patter of the Else If [$Context = “Activity”] section; this is where you actually script arriving at your new table’s records.

That’s it.

Changing the display of Search Results.

The search results are written out using a looping script, so you have very fine control over how each table’s (each subjects’) results are displayed. Edit the script “Search - Display Results ( Subject )” and find the comment “Actual result display follows”. In the SetField() line following that comment you’ll find sections for each of the tables we’re searching following something like $Subject = "Contact". The actual fields displayed and their formatting is contained with a List() statement in each section. Edit the contents of that List() to change the display.

Changing the order of Search Results.

We’re doing some interesting things to keep the search results relevant but still keep the processing speed down. You may want to change some of these behaviors depending on your needs, so here is an overview of how the search results’ sort order is determined.

For everything except the contacts table, we’re presenting results with the most recently created items first. To to this we don’t sort the search results, but we walk through them backwards, from the last result forward) as we’re compiling the results to be displayed. You can find this behavior in the script “Search - Display Results ( Subject )”.

When it comes to contacts, we wanted to show them in alphabetical order, even though that puts a load on the search as we have to sort the found set of contacts. You can find or modify this sort in the script “ Search Contacts”. Note that this sort has the results sorted alphabetically but descending. This is because we’re always walking through the results backward, so we want the names to line up that way. Feel free to change this sort or eliminate that sort step all together for more speed.

(855) SEEDCODE
[email protected]
Follow us: