Save a Found Set
What if you want to allow a user to store a found set of records for future retrieval? You could show them how to create a script with Perform Find [Restore], but that is dangerous. What if they decide to investigate the scripts you created and accidentally or purposefully modify it. It is better to never let users have access to ScriptMaker by dimming the menu item using Access Privileges.
This technique will show you how to enable a user to store a found set of records and then restore it whenever they want. The technique is based on a concept that has already been discussed in the Isolating a Record technique described on slide 2.
The idea is to use the Copy All Records script command to grab all the serial numbers from the current found set and place them in a global text field. Copy All Records copies all the field values from the current layout on all the records in the current found set. Since you only want to grab a unique identifier (the serial number) from each record, you need to visit a special layout for copying the records. The layout only contains the serial number, so it is the only field copied. Once the serial numbers are copied, they are pasted into a global text field called Found Set.
Each serial number that is pasted into the Found Set global field is separated by a return because of the way the Copy All Records script step works. Copy All Records grabs values in tab-separated format, which means a tab between each field and a return between each record. Since there is only one field, the Serial Number field, on the layout where Copy All Records is invoked, only the serial numbers are copied. Here is what the data might look like:
2
7
8
10
The Found Set global field is also part of a same file relationship. Remember that a same file relationship is one that relates to itself.

NOTE: A text or global text field can only store 64,000 characters on each record. That's a lot of serial numbers, and probably more than you'll ever copy. However, it is good to know the limitations of any technique before you run into the problem.
Once the serial numbers are stored in the Found Set global field, a simple Go to Related Record script step with the Show Only Related Record option will restore the found set. That's because the returns between each serial number allow them to act as separate matches in the same file relationship. So, if the values 2, 7, 8 and 10 are stored in the Found Set global field, the Go to Related Record script step will find any record that has a serial number of 2, 7, 8 or 10.
TIP: This technique will work in a multi-user environment because global fields are stored locally at each guest.
The technique shown here only allows a single found set to be stored by each user. There is a more powerful implementation of this technique which allows users to store as many found sets as they want. The idea is to store the return separated serial numbers on their own records in a separate database. That means the Found Set global field will now be a regular text field instead of a global text field. The relationship will originate in the Found Sets database and connect to the database where you want to restore found sets. When a found set is stored, all you have to do is create a new record in the Found Sets database and paste the values there along with the user name and a title identifying the find. To make restoring a found set as easy as possible for the user, create a nice interface that allows them to locate all the found sets they have stored.
Download an example FileMaker file
.
DONE
|