“Final call for flight …”

hub_001

A couple of weeks ago, we talked about the “Beam me up, Scotty” or “tele-porting” method. This technique described how you can transfer found sets from one table occurrence to another.

This week's technique will show you how you can write a re-usable script to go to a certain record or found set, independent of the current context.

We call this technique the “hub” method. It is also described in the myFMbutler/SHpartners Development Guidelines.

What is a hub?

An airline hub is an airport that an airline uses as a transfer point to get passengers to their intended destination. It is part of a hub and spoke model, where travelers moving between airports not served by direct flights change planes en route to their destinations.
(source: http://en.wikipedia.org/wiki/Airline_hub)

In fact we will do the same thing. We will build a hub to use only as a transfer point to get to a certain location.

The Beer Database
Example File Step 1

We start with a very simple database about Belgian Beers that contains two main tables, “beers” and “beer types”. This FileMaker file makes use of the Anchor-Buoy method.

If you're not familiar with the Anchor-Buoy method, you can find more information about it on Kevin Frank's web site:
http://www.kevinfrank.com/anchor-buoy.html

hub_002

We have created 3 layouts:

Dashboard: This layout contains a portal with all my favorite beers.
hub_003

Beers: This layout shows the detailed information about the beer.
hub_004

Beer types: This layout shows a beer type with all corresponding beers.
hub_005

It would be nice, when we click on a portal row, to navigate to the detail of the portal row, and when we click on top of the portal row, to navigate to a found set equal to the records in the portal.
We could do this with the script step “go to related record”. The only problem we have is that we need to create a different “go to related record” script for every relation we have defined. In a simple application, this is no problem, but in complex big solutions it can be a huge job to maintain all these scripts.

Wouldn’t it be nice if we could call a single script “Go to beers” to navigate to a beer record, without having to bother were we are in the application ?

We can do this by passing the primary key(s) to the script as a script parameter.

The hub
Let's create a new table called “hub” and define one global text field “_k_hubid”.
For every table we have defined in the database we make a relation between the primary key and the “_k_hubid”.

hub_006

The next thing we have to do, is to create one layout based on the table occurrence “hub”.

“Go to beer” script and “Go to beer types” script
Now create a new script “Go to beer”.

hub_007

If we want to create the script “Go to beer types”, we only need to duplicate the “Go to beer” script and change a single script step:

hub_008

The Hub in action
Now we can add our scripts to the layouts and pass our script parameter.
If we want to go to all related records shown in the portal, we can use the List() function.
Also notice the button on the beers layout (go to beer types). Although we have no relation to ”beer types” in the graph, we can navigate to it.

Download the example file here.

Leave a Reply

You must be logged in to post a comment.