Software tips, techniques, and news.

By Weihao Ding  Posted on  March 8th, 2017  in  Free Downloads, Claris FileMaker

Building a Dynamic and Robust FileMaker System

Have you ever inherited a system built by someone else, changed a field’s name and everything stopped working? The issue, hardcoded names used in indirection, makes the system fragile. FileMaker provides developers many methods to add flexibility using indirection. However when these instances of indirection are not treated properly they will raise all sorts of problems. In this article we will discuss good practices regarding indirection that will help you build a dynamic and robust FileMaker system.

What is indirection (and what could go wrong with it)?

Indirection in FileMaker refers to the ability to reference an object (table, layout, value list, field, script) by its name, instead of its internal id. For example, I can use a few lines of code to tell a script to do something if the user is in field "CONTACT::firstName".

<span class="long-link">If [ Get ( ActiveFieldTableName ) & "::" & ( ActiveFieldName ) = "CONTACT::firstName"]</span>
    Do Some Code
End If

It looks normal at first glance but there are actually two issues with this approach and with many other uses of indirection: The first issue is that if not treated carefully, renaming objects may break indirection. In our example, if I rename the field "firstName" to "first_Name", it will break my script because there are no fields named "firstName" anymore. The second issue is that indirection is not considered as a reference in DDRs. So if you use analysis tools like BaseElements to check where field CONTACT::firstName is referenced, that script will not be included.

Building a Dynamic and Robust FileMaker SystemHow to write robust indirection

With that being said, how do we write robust indirection? Robust indirection will try to dynamically grab an object name and use it in your solution. So we should try to avoid hardcoding the following in our solutions:

    • Table occurrence names
    • Layout names
    • Field names
    • Window names
    • Value list names
    • Script names

Following this guideline, for our example we want to get rid of the hardcoded TO names and field names and instead, dynamically grab the field's name.

<span class="long-link">If [ Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) = GetFieldName ( CONTACT::firstName ) ]</span>
    Do Some Code
End If

In this case, if I change the field name to first_Name, that script will still work. Also now field CONTACT::firstName is considered as referenced by this script in DDRs. The magic is being done by the function GetFieldName (). This function actually takes a direct reference to the field and translates it into a name.

However, not all objects in FileMaker have a function like GetFieldName to translate direct references into a name. For example, if I want to have one script perform different activities on different layouts, in order to determine which layout the user is on, it seems unavoidable to use something like:

<span class="long-link">If [ Get ( LayoutName ) = "Contact - Data Entry" ]</span>
    Do Some Code
End If

which suffers from the same problems as the first example: you can't rename your layout and it won't be recognized as a reference in DDRs. What do we do now? Well, in this case it will be hard to solve the second issue. But we can do something about the first issue so we can rename our objects with confidence.

Internally FileMaker assigns an internal ID for every object in the system. When you use script steps like Set Field [] and point that to a field, FileMaker will store the ID of the field with that script step. That is why no matter how you rename your field, Set Field [] script step will never be broken.

FileMaker has a series of design functions that provide you with information about these internal IDs. With some custom functions built upon them, we can grab the internal ID for any table, layout, value list, field or script and use them in our calculations and scripts. Be sure to try them out in the demo file of this article.

So let's say the internal layout ID for layout "Contact - Data Entry" is 2. With the help of our custom function "getLayoutName" (getLayoutName will take an internal layout ID and translate it to that layout's name). I can rewrite my script to be:

<span class="long-link">If [ Get ( LayoutName ) = getLayoutName ( 2 ) ]</span>
    Do Some Code
End If

This way I can rename the layout and still have the script working. As mentioned before, referencing internal IDs still can not be seen by DDRs as a reference. Also it makes reading the code harder. So be sure to comment your calculation or your script when you use internal IDs to enhance readability. Here is an article if you want to learn more about using internal IDs in your solution.

One last example I want to mention here is about using the ExecuteSQL function. ExecuteSQL is a context independent way to retrieve data. It can save a lot of time when developing complex reports or charts. However ExecuteSQL requires indirection by nature. If not treated carefully, renaming of fields or tables will break the SQL statement used in your ExecuteSQL. In the demo file I included two scripts showing how to use some custom functions to make your SQL statement dynamic and robust.

How do I identify indirection in my own solution?

Now that we have went through two examples of how to write robust indirection, you might want to take a look at your own solution and see if there are any potential problems in there caused by indirection. How do I find all those instances? Use an DDR analysis tool like BaseElements or InspectorPro to search for indirection.

Here are the functions you should be searching for:

    • Get ( LayoutName )
    • Get ( ActiveFieldName )
    • ValueListItems ( )
    • Evaluate ( )
    • ExecuteSQL ( )
    • DatabaseNames
    • FieldBounds ( )
    • FieldComments ( )
    • FieldIDs( )
    • FieldNames ( )
    • FieldRepetitions ( )
    • FieldStyle( )
    • FieldType( )
    • Get ( ActiveFieldTableName )
    • Get ( ActiveRepetitionNumber )
    • Get ( LayoutNumber )
    • Get ( LayoutTableName )
    • Get ( ScriptName )
    • GetField ( )
    • GetFieldName ( )
    • GetNextSerialValue ( )
    • GetNthRecord ( )
    • LayoutObjectNames ( )
    • Lookup ( )
    • RelationInfo ( )

and here are the script steps you should be looking for:

    • Set Field by Name[ ]
    • Go to Layout[ ] (By Name option and By Number option)
    • Go to Related Record[ ] (By Name option)

Once you find all the instances that could potentially use indirection you can go over each one of them and determine if they uses hardcoded names and should be updated.


Using indirection in FileMaker definitely gives your solution more flexibility, allowing you to accomplish complicated tasks with fewer lines of code. If you follow what we discussed in this article carefully, you should be able to build a dynamic yet robust FileMaker system. Feel free to contact us if you need any assistance with your FileMaker application.

Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.

Download the Dynamic and Robust FileMaker File
Please complete the form below to download your FREE FileMaker file.
FileMaker Experience *
Terms of Use *
OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This file is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free file, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.
Weihao Ding thumbnail
Weihao Ding

Weihao is a FileMaker Certified Developer, a creative thinker and a great communicator. He thrives on utilizing his keen technical skillset to solve problems in a manner that will make a positive difference for customers. His passion and drive to demonstrate excellence is evident in all of his work.

FileMaker 18 Certified Developer
FileMaker 17 Certified Developer
FileMaker 16 Certified Developer
FileMaker 15 Certified Developer
FileMaker 14 Certified Developer
FileMaker 13 Certified Developer
FileMaker 12 Certified Developer
FileMaker 11 Certified Developer
"We were actually able to add more features than we thought would be possible within our budget. We always experienced a ‘can do’ attitude and DB Services was incredibly patient and easy to work with."
Courtney Hartman
Art Director
"The new FileMaker custom website interface is very user-friendly and easy to follow for our clients. In addition, it is much faster than the old Instant Web Publishing (IWP) interface. Thank you and all the others who have helped us out at DB Services. I am very grateful for the excellent service you provide us. Its nice to know we can call you for help if we have an issue."
Wayne Capek
"We needed a solution that would simplify the administration of our responsibilities under our contract with the State of Indiana. We have seen a dramatic increase across the state in the number of potential foster and adoptive parents that have begun the preparation and training process. This increase has resulted in a significant opportunity for children available for adoption. That’s a big win for everyone! And it’s all because we can refer potential parents to the proper state contacts efficiently and quickly."
Chris Morrison
Executive Director
"Thank you for all of your expertise and valuable help. I am so grateful to have found DB Services."
Linda Findlay
"Thank you for our new database system. We transitioned from a carbon copy paper based system to a digital database. The software has saved us time and money. We used to archive all our jobs in cabinets, now we can look up a job in seconds from anywhere. The software allows us to easily email estimates to our customers in pdf format. In a year there was a return on investment just from eliminating the purchasing of our carbon forms."
Todd Cartmel
"The new system allows us to create and track jobs for customers along with inventory, something we had been doing with separate word and spreadsheet files. Because it’s now so intuitive, new staff members are able to begin using the database immediately without our usual training session and ‘cheat sheets’ for getting around within the file."
Tom Andrews