Discover a Few FileMaker Tips and Tricks
One remarkable thing about working in a supportive and dynamic collective like the FileMaker developer community is that we can share our experiences and techniques. With Claris FileMaker, there are often many solutions to any given problem, and over time our community has come up with some innovative and creative ways to use FileMaker. Unfortunately, these things are usually not found in the standard documentation, but developers share them among themselves. Here are three compelling tips and tricks that we discovered recently.
Users often want, and consequently, ask developers to provide the ability to sort columns in the list view by clicking on the column’s label. Unfortunately, this can be tedious, and most solutions tend to pass a parameter indicating which field to sort by followed by a long list of IF statements: If $fieldName = “First Name”, sort by First Name, etc. Another solution we’ve seen is creating separate scripts for each column, which can clutter our script workspace.
However, FileMaker offers a script step called “Sort Records By Field.” This script will sort the records by the field we specify or the currently active field. So instead of having a long list of IF statements, we only need two steps.
The essential thing here is to make sure we set the object name of the First Name field so we can specify it in the “Go to Object” step. The script will go to the object we specify and then attempt to sort it by that field. We can reuse the same script and just pass in the object name of the field to control the sort. Once we get our heads around this method, extending it to have the column sort in either ascending or descending order by setting a global variable with the field name and the sort direction is relatively simple.
PREVENTING ERRORS FROM BEING LOGGED
We often use the Go To Next Record [Exit after Last] script when looping through records. There’s absolutely nothing wrong with this method except that it will create an error when it exits the loop. FileMaker will log this error within the server logs. The error can cause local server admins some consternation – we have often fielded questions from clients saying: “This script is creating errors on the error log on the server; is there something wrong with it?” To avoid this scenario, we can simply add a quit script step calculation to exit the loop. Just before the Go to Record/Request [ Next ] step, add the following:
This command will exit the loop when the loop gets to the last record number without throwing an error.
USING A HIDDEN OBJECT TO HIDE THE LAYOUT BACKGROUND
By default, the layout background is usually a different color than the body part. However, when we resize the window to be larger than the body part, this can result in a weird-looking situation where the body part stops, and the layout background is revealed.
To solve this, we will have an object on the layout with the auto-sizing feature enabled to anchor the object to the right and bottom of the layout. But sometimes, we might not have an object to select to do that. The trick here is that even if an object is hidden – either by using a hide condition or by putting it off the layout to the right of the body – the auto-sizing for that object will still affect how the layout is displayed. We will often just put a text object at the bottom right of a layout with all four anchors on and either give it a hide condition of “1” (which will hide it all the time) or just put it just to the right of the layout.
And there we go! Three quick tips and tricks you can do to take your FileMaker development to the next level.
Check out more FileMaker development tips and tricks, like moving data from repeating fields and recording and tracking GPS data using the FileMaker location function.
March 16, 2023 @ 1:10 pm
Very nice – I LOVE all 3 tips. The loop one is definitely cool and I love the box with the 4 anchors – I can’t tell you how many times I’ve run across that problem before.
Lin in Austin
March 16, 2023 @ 5:56 pm
I really like the Sorting Columns trick. At first I thought that it would not work for me because I usually do not have fields open for entry on the Layout for the user to input into. I use Edit screens so I can track changes or allow the user to cancel their change. So there is no way to make a Field the Active Field. However, there is a way to have the best of both worlds with a second trick. Create a Master Detail Portal in the header (must be onscreen). Put the Fields to sort by in the Portal and give them an Object Name. Make the Portal Fields open for entry (Inspector – check the Browse Mode box). Make the Portal wider and move the Fields in the Portal to the right so there is some space in front of the first Field so the Fields are “right justified” in the Portal. Now make the Portal smaller so only the space on the left (before the first field) is showing – none of the Fields should now be visible in the Portal. Now the Script can still get to the Fields to make them Active, but a user cannot! You can make the Portal size 1 Pixel by 1 Pixel so the user will not even know it is there. The Script will use the Go To Object Step like you explained. I include an extra Go To Object Step at the end (after Sorting) that does not specify an Object Name, which will get the cursor out of the Active Field.