Mac OS X, Windows
Koen Van Hulle
FMP 8, 8.5, 9, 10, 11
SHpartners / myFMbutler
File Type: FP7
FileSize: ~ 1.03 megabytes
This demo 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.
Set Error Capture [On]
Exit Script[Result: False]
Go to Layout[”hub” (hub)]
Set Field [hub::_k_hubid; Get(ScriptParameter)]
Go to Related Record [Show only related records: From table: “hub_beers”; Using layout: “Beers” (be_beers)]
If [Get(LastError) <> 0 ]
Go to Layout [Original layout]
Exit Script [Result: False]
Exit Script [Result: True]
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.
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.
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.
We have created 3 layouts:
Dashboard: This layout contains a portal with all my favorite beers.
Beers: This layout shows the detailed information about the beer.
Beer types: This layout shows a beer type with all corresponding beers.
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.
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”.
The next thing we have to do, is to create one layout based on the table occurrence “hub”.
Now create a new script “Go to beer”.
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.
FileMaker Inc. provides this content on an “As Is” basis, without any warranty, and subject to the terms of the FileMaker Technical Network Agreement. FileMaker makes no representations and is not liable for any content or related information. You may use the content as part of your own solutions and for your customers, but you may not otherwise publicly distribute any content that you did not submit. ©2009-2011 FileMaker, Inc. All Rights Reserved. FileMaker is a trademark of FileMaker, Inc. registered in the U.S. and other countries.