From Dwayne Wright PMP
Certified FileMaker Developer
Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit. For the best experience, please visit the journal directly by clicking (here).
In this example, we are sorting a portal by using a very easy technique with the somewhat obscure function of GetField ( fieldName ).
The GetField function can return at least two different results based upon if you include quotation marks in the syntax of the field name. If you use quotation marks, you get the information inside of the field. If you don’t use quotation marks, it looks at what is inside of that field. If the data inside the field you reference within the GetField parameter is equal to the name of another field, it returns the contents of that field for that record.
Without quotes - value in the field
With quotes - name of the field
THE USER INTERFACE MECHANICS OF THE EXAMPLE
The way this example files works is that you make a selection from the set of radio buttons First Name, Last Name, City, State or Area Code. Then you click the Sort It button and the portal complies. In many cases, you don’t have to click the Sort It button. That is because the Sort It button does not run a script. All it does is exit the record and allows the screen refresh option to update the portal. If you are using FileMaker 10 or higher, you could add a simple script trigger and remove the Sort It button completely. This example was created way before FileMaker 10 was released and I thought the “not really a button” button technique may still be an interesting concept to show you.
UNDER THE HOOD
We have two fields in this example, a global text field named Portal Sort. It is the field we have assigned the radio buttons / value list. The second field is a calculated text field using the GetField function. It is also the field was are using as our sort setting in the Define Relationships dialog box. The field is named Portal Sort Calc and the calculation is GetField(Portal Sort).
So let’s say we have a field called “Variable” and currently it has the text string “First Name” in that field. In that same file, we also have a field called “First Name” and that field contains the text string of “Dwayne.”
If we setup the function as GetField(variable), the function will return the text string of “First Name” as it’s result.
If we setup the function as GetField(“variable”), the function will return the text string of “Dwayne” as it’s result.
Hopefully, you can see what we are doing. The GetField function returns the data inside of the field we specify with the radio button. The only thing we have to watch out for is mixed field types. An example would be a date field is being used when the GetField function returns a text result.
An example file can be downloaded by clicking (here)
More info about the author and FileMaker in general, contact me at email@example.com.
© 2007 - 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.