New Record Only Relationships

 <  Day Day Up  >  

"New Record Only" Relationships

You might not want to have to write scripts to create new related records for display in your portals. Scrolling to find them can still be an issue in some cases, and a script still requires a user action to be executed or performed.

An alternative is what we're calling "new record only" relationships. To establish them, you need to rely on the auto-entry options in FileMaker Pro, the triggering behavior of the Evaluate() function, and the order in which FileMaker Pro performs certain tasks .

The technique described here enables you to use related fields through a relationship that allows creation of new records, just as if you were planning to allow users to scroll to the end of a portal, but that don't require you to scroll to the bottom of a portal to do so. The related fields you'll use provide a data entry area outside the portal that is always available to create new related records. When users type data into the fields, a new record is instantly created, but then on committing those new edits, the relationship is immediately invalidated so that these new record fields remain blank and ready for more data input.

This then obviates the need for scripting, and opens up some possibilities for user interface and working with portals.

Consider the Relationships Graph shown in Figure 16.5, where a neighborhood is related to many houses . The second of the two relationships is set to allow for the creation of related records. Note that we have created two foreign IDs in the related table occurrences and that the two relationships are different.

Figure 16.5. This Relationships Graph represents two equijoin relationships. The temp relationship is set to allow creation of related records.
graphics/16fig05.jpg

The rest of this technique relies on field definitions. The basic approach is that you allow the foreignID_temp to be populated via the Allow Creation of Related Records function, but then immediately set the field to zero when the record is committed.

This requires that two tasks happen: that the foreignID_neighborhood gets set, and that, only after this field is set, foreignID_temp is cleared.

To accomplish the first task, set foreignID_neighborhood to foreignID_temp , using an auto-entry calculation. At an instant before the temp field is cleared it will contain a proper value for this house record's neighborhood ID.

The second task, clearing the temp field, is accomplished if you set the auto-entry options for foreignID_temp , turning off the Do Not Replace Existing Value for Field (If Any), with a formula of:

 

 Evaluate (     If ( IsEmpty (foreignID_neighborhood); foreignID_temp; 0);     foreignID_neighborhood ) 

Notice that the foreignID_neighborhood is defined as a trigger for the Evaluate function. When foreignID_neighborhood is populated, by its own auto-entry pointing to foreignID_temp , that event then triggers foreignID_temp 's auto entry ”which then sets itself to zero. The technique assumes you have no records in your neighborhood table with a primeID_neighborhood of zero. Because the second relationship based on the foreignID_temp is invalidated after this process is complete, you can place data entry fields on a layout, tied to your second temp relationship, that are then cleared after a new record is committed.

 <  Day Day Up  >  


QUE CORPORATION - Using Filemaker pro X
QUE CORPORATION - Using Filemaker pro X
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 494

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net