|
|
|
Navigate: | My Mac Online | The Archives | July 1999 | FileMaker 101 - Part 16 | |
![]() |
|
![]() Part 16
My Mac Magazine manavesh@mymac.com
Globals & Filtered Portals
Filtered Portals
We may even have to define a calculation field and/or set a field, often a global, to get a custom key for the portal, in either the current file, the portal's records file, or both.* This is a "filtered" portal. Remember that portals are based on relationships; and that relationships are pretty much independent of the Found set of records in any file. They are only dependent on what the key is for the relationship. This key can either be a regular field in the current record or a global field, which is, by definition, the same for, and available to, all records in its file. The portal contains the records that match the key on the other side of the relationship, either in another file, or, in the case of a self-relationship, within the same file, no matter what records are currently found. The rest of the article will attempt to illustrate filtered portals using examples in last month's sample database, Eats, beginning with the main file Food, on the layout Food Choice.
Groups Portal
Foods Portal
This global field has a relationship to a Group ID field that has been manually entered in every Food item just after record creation.* In this case the Group ID is the encompassing ID, and the food items are the records showing within it. I've also created a relationship between the global Group ID g field and the Group ID field in Groups. This allows me to show the Group name in a field by itself just above the Food portal, so you get immediate feedback on what choice you made in the first portal. The thing to remember here is that by using globals to make the choices, you are able to change the view of the records, but as yet you haven't either made any actual changes to any of the records, or even moved away from the current record. That is what makes globals and portals a good match.
Food Self-relationship
Filtered Group ID You could create another file to hold the multiple instances of each food. But I found that all the fields I wanted for a food would work with this self-relationship. The number fields, Amount (on hand), Threshold (below which it was time to buy), and the calculation field Buy; If (Amount<=Threshold, 1, ""), are the same for all instances of each food. If I had 1 cube of butter, I'd have 1 no matter whether it was breakfast or dinner. You can modify the number field Amount, but you can't modify Buy; it is a calculation. One of the advantages of portals, versus other value list choice methods, is that not only can you show several fields at once (vs. 2 at most for defined Value Lists), but you can combine navigation (clicking on the name), data input and visual feedback all in the same portal. The disadvantage is that they take up a lot of space on the layout.
Constant=::Buy Portal
Refresh Problem
A simple way to force this is a script with two steps:
Concatenated Keys with Portals
Meals File
The 3rd portal uses a concatenated global field, Meal-Group IDg
It is related to a field in Foods, Meal\If\MealGrpMark
The first step is simple, but has a twist: Meal-Group ID The reason for the "IsEmpty" is to correctly "lookup" a first entry mark (below). Otherwise the lookup occurs as soon as you exit the first field, Meal ID in this case; it doesn't wait for you to enter the Group ID. The second step is to mark the first entry of every unique value in Meal-Group ID. Meal\GroupID\Mark, number, is a lookup. Using a self-relationship on Meal-Group ID it looks up a 1 for a unique entry. Here are some examples of unique entries; breakfast dairy, breakfast grain, lunch dairy, etc. The last step puts the Meal ID in a field for those unique entries. Meal\If\MealGrpMark= If (MealGroupIDMark, Meal ID, "") The reason for all this is simple actually. The Meal is the encompassing ID. You choose the Meal in the Meal portal. But for the correct groups to show in the next portal, you need to have the Meal ID in only those records in Foods that are the first unique entry for that Meal ID and Group ID. If the Group does not have any entries for that Meal, you don't want it in the portal. If the Group has more than one entry for that Meal, you only want one of them. There is probably a way to do this by using another "join" file for Meals & Groups. But I tend to keep things in the fewest number of files. In this case I started with the list view in Foods, keeping all the data entry there, even for the Meal and Group files. You can experiment with it.
Global Concatenated Key
[Correction: In the example file it's Meal\Grp\If\FoodMark, =
Clear the Portal, Matey Use this technique for the first portal whenever you have three or more linked choice portals, otherwise you'll have values still showing in the third one from the last time it was used; but they won't be correct, and it won't be obvious that they aren't.
Fenton Jones
FileMaker 101 - Previous Columns
|
|
Copyright ©1995-2000 My Mac Productions, All Rights Reserved |