Level: Intermediate, Version: FM 8 or later

Magic Key, part 2

I ended yesterday’s article promising a couple improvements on the techniques showcased therein. To avoid unnecessary repetition I am going to assume you have read it.

The first improvement is to eliminate the highlighted steps in the “parse current field” script. Is it really possible to create a related record and populate multiple fields in that record using a single Set Field step?

Absolutely, and you can follow along in today’s demo file, magic-key-multipredicate-check-box-reporting, if you are so inclined.

Multi-predicate “Allow Creation” Relationship

We want to create a record in Tasks, like the one below, and populate all the highlighted fields using a single Set Field step…

…so we need to change the Magic Key relationship from single-predicate…

…to multi-predicate as follows (having previously defined a new global text field, g_category, in Volunteers):

As long as all the relational operators are equi-join (=), “allow creation” will work, and the “parse current field” script can be divested of a couple Set Field steps. The other change to this script is that the highlighted line now populates g_category, as opposed to $field in yesterday’s demo file.

Session Key

The second improvement is to make the routine “multi-user friendly”, because as things stand in yesterday’s demo, if two users run the routine at the same time the result will be a flawed report, with any number of possible negative consequences, including:

  • Business decisions made based on the faulty report
  • Loss of confidence in the system
  • Loss of confidence in the developer
  • Loss of confidence in FileMaker Pro

To help avoid this, we’re going to implement a “session key”, as follows:

1. In Volunteers, define a global text field, g_id_session.

2. In Tasks, define a standard text field, id_session.

3. Add a new predicate to the relationship between volunteers and tasks_create, linking the fields you created in steps 1 and 2.

4. Add the following steps to the “startup” script.

5. Add the highlighted steps to the “report” script.

Now you can run the report with confidence, even in a multi-user environment.

1 thought on “Magic Key, part 2”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.