Isolate Any Record, Anywhere, Anytime and Any Context With One Script

There are some things that are easier to explain through examples.  Putting the Set Field By Name script step to work is definitely one of them.  It’s not a complicated process, but seeing the new Indirection capabilities that Filemaker 10 has to offer makes a much stronger impression than trying to talk through it.  Also, all my introductory quips for “isolating” and “isolation” were turning out quite depressing.  So, here is how we used to find a specific record, and how we can do it now.

The Old Way

For this article I’m going to assume you are using two methods that are a part of our development process.  The first is multiple parameter passing (feel free to check this out if you’ve never run into it before) and the second is Safe Find.  Safe Find is a script we use to safely run a find and capture any errors that occur and return them without throwing an error dialog.  Here is a copy of the actual script:

Performing a Safe Find

So, now on to the concept of Indirection.  Here is how we used to find customers using our standard naming conventions, parameter passing and error handling:

Finding a Customer

Now, here is how we find orders:

Finding an Order

And now for something completely different.  Here is how we find vendors:

Finding a Vendor

By now you’re probably seeing a trend in our scripting that has driven me nuts since day one.  In Filemaker 9, we had to maintain a separate set of scripts for each context that we wanted to operate in.  If we want to find a Vendor, that’s one script.  Find an Order?  That’s a second script.  Customer?  A Third script.

The New Way

Here is how we can find a Customer, Order or Vendor now:

One is the Lonliest Number

This little beauty does something that makes us here at Six Fried Rice absolutely giddy.  I can call it from any layout, pass it an ID and it will isolate the record with the corresponding ID without any further hassle!  It is completely context independent.  Essentially we now have a single script to replace every find by ID script we have ever created.  A huge part of development model revolves around using structures, systems and conventions to centralize and simplify the development process.  This particular script is a perfect example of a very simple application of a very useful feature to cut out a huge amount of redundancy in a systems.

Note: This script does require that a few things are in place before hand.  For one, you’ll notice that we use the Set Field By Name to set “ID” to the parameter that is passed in.  This only works if you strictly follow the naming convention that dictates having a primary key field called “ID” in every table.  I’ll be posting an article going much deeper into our own conventions, but for now remember that to use a script like this, you must have consistent naming conventions throughout your system or the script will not execute correctly.

← Previous Page