Temporarily saving found sets

Temporary Found Set save

FileMaker Pro 7 has an interesting use of the Go To Related Record (GTRR) command. The function is "overloaded" which means that it behaves differently depending upon how or where you use it.

The common usage of GTRR is to show and list all records in a related table occurence that are linked to the "current" record, whatever that might be. For example, if the current record is a client record in a layout based on the client table and the client table is related to an orders table, you can use the GTRR from Client to Orders to list the orders for the client in one step.

client orders

Warning: if there are no related records when performing a GTRR, FileMaker Pro 7 will show the related table (layout), but will not change the prior "found set" in that related table. This is different to how FileMaker 3 through to 6 behaved which set the found set to zero records. This behaviour is documented, if a little unintuitive. Always count the related records before doing a GTRR - especially if you plan to delete related records.

Things get interesting if you GTRR to a layout, and that layout is based on the same table as originating layout, and the layout has no connection to the originating layout.

FileMaker Pro will switch to that layout and carrying the found set and sort order over to that layout.

Saving found sets

So, say that you have some process that is going to operate on some records, but when that process is complete, you want the user to return to the original records and in the same order.

Add a new, stand-alone table occurrence to the relationship graph based on the same table as the original. This table must not have any relationships that connect to the start point. Add a layout based on that TO as well.

unrelated table

In the example here, a table occurrence called orders_save has been added to the relationships graph and is based on the orders table. A new layout based on orders_save is also defined.

unrelated table

Before you perform your magic with ScriptMaker, go to the layout with the found set and sort order you wish to save, GTRR to the disconnected table, return the layout and away you go.

When you finish your magic, go to a layout based on your save table occurrence, GTRR back to your original layout and you will have restored your found set and sort order.

Your final script would have a structure similar to this:

unrelated table

Do note that this technique is meant as a short term save, not as a technique for saving found sets long term. To do that, you still need to build up a "stacked" set of record keys, which can be very slow on large found sets.

10/11/04 (cleaned up 7/1/05)

Rob. FileMaker. Words.