As-You-Type Search Filtering using Script Triggers

Check out the new “Tips-n-Trick” file just posted to the “Downloads” section of our web site, contributed by Mike Duncan, Lead Developer at Excelisys, Inc.

FileMaker Pro 10 introduced native script triggers as a tool for developers to utilize in their solutions. This example demonstrates the usage of a search filter, which many FileMaker developers are familiar with in complex portal filtering solutions. Now, with the use of script triggers, it is simple enough to implement the same functionality but you are not restricted to displaying results in a portal, and therefore have much more flexibility in the interface. Instead of being required to set a complex key that drives a relationship, your search script can be as simple or exotic as your solution requires. One key difference available in FileMaker Pro 10 is that you no longer need to wait for a field to be exited in order to trigger an action, allowing interaction between the user and database not available before without the use of third party plug-ins.

This example is a simple implementation of script triggers by using the OnObjectModify trigger set on the global fields that are being used to provide search criteria on the sample data. As the user types search criteria, a search script gets run, narrowing the search results in real time. Also used in this demo is the new functionality to set a field by name. This is used to allow the user to select a field to search on, which is used to set the field by name that is searched. This sounds simple enough, and displaces the need for large, complex branching “if” statements in a script editor that might have duplicated this functionality in previous versions of FileMaker.

Since these fields wouldn’t be applicable in Find Mode, we also set an object with text that displays only when you are in Find Mode that alerts the user to this fact as a reminder, as well as graying out the filter fields. This is done using conditional formatting to change the appearance of text and layout objects that are dependent on the current mode.

Script Triggers in FileMaker Pro 10 are an absolute game changer for developer in what they can accomplish. Hopefully this example provides a small peek at the potential that this new functionality provides.

Special thanks to Brian Dunning for providing the sample data used in this demonstration that is available at http://www.briandunning.com/sample-data/

Excelisys

Explore the eX–Cetera Blog