From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer
When you code something in FileMaker, you can reference that something directly (often called hard coding / direct reference) or you may have an opportunity to use a calculation to build the reference. If you reference something by a calculation, you may be able to make it more flexible and dynamic. Many times a calculated reference is called an indirect reference or a dynamic reference.
Let us start by using the Go To Layout script step as an example of literal vs indirect (hard coded vs dynamic). With this script step you can choose an existing layout in the file. This would be a literal reference to the layout you want to go to. You can also choose to go to a layout by a calculated result (either the name of the layout or its position number in the overall count of layouts).
By using the calculation engine to determine where you want to go, you are using an indirect reference. This is because you can setup any number of “what if” scenarios to branch what layout you will eventually end up on.
So you might be thinking, “so which do I use (direct or indirect)?” and that is a very good question. There is a reason why you have both options provided to you by FileMaker. This is because there are times one is the better option than the other.
If your use of a reference is pretty fixed, then a direct reference is probably your best option. In the example of going to a layout, if you change the name of the layout, your go to layout script step will work fine with a direct reference. FileMaker will update the direct reference used by the script at the same time you change that layouts name. However, it will not do the same if that layout name is within a calculation (used by indirect references).
If you want a script to branch in multiple possible directions, creating a direct reference would be a pain. Say you have six different user roles in your company and you want a script to go to a specific layout based upon that users role. First you would likely create a security privilege set for each role. Then you can use a Get function to know what privilege set is the current one for that user.
Branching what layout a user will go to by a direct script method would mean you would need an IF or ELSE IF script branch for every account. This works but it can be a bit tedious as you would need to update the script for every business role and imagine if you have a dozen or so roles within the company.
Now imagine you can put all those roles into one CASE statement and then branch via a single calculation. You can perform the same action with a single go to layout step (you don’t even need the IF / END IF script steps) if your Go To Layout [by calculation] would contain a calculated value such as ...
Get ( PrivilegeSetName ) = "Sales", "FORM_sales",
Get ( PrivilegeSetName ) = "Front Desk", "FORM_frontdesk",
Get ( PrivilegeSetName ) = "Accounting", "FORM_accounting",
Here the Go To Layout script step would go to the correct layout for the first three roles and if none of them are the current role, it goes to a default layout.
Another great example is the Go To Object script step. This script step goes to a named object on a particular layout such as a tab on a tab panel, button or field. You can put in the specific name of the object (literal reference) or you can use the calculation engine via the Specify button (indirect reference).
If you name all your layouts or objects the same between multiple files, you might be able to copy and paste whole pieces of code from one file to the next and it works (or needs minimal tweaking).
More info about the author and FileMaker in general, contact me at firstname.lastname@example.org.
© 2008 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.