The FileMaker platform keeps getting better. The yearly release schedule gives us plenty to look forward to in new features, and the timeline gives us plenty of time to get to know what has been included. One of the new features is called “Default Fields”. We can now set up default fields to be created with each table in each file. There are plenty of articles out there already, and the knowledge-base article is out now. But I’ve seen some questions in the forums, sometimes the same ones. I did some research and put together the answers here. Let’s dive into FileMaker Default Fields.
Where are the Default Fields?
FileMaker 17 includes the default defaultFields.xml file in this location:
- Mac: Applications/FileMaker Pro 17 Advanced/FileMaker ProAdvanced.app/Contents/Resources/en.lproj/DefaultFields.xml
- Win: <drive>:\Program Files\FileMaker\FileMaker Pro 17 Advanced\Extensions\English
This is just the place to get the defaultFields.xml file. You shouldn’t move it. Just copy it and paste it to the proper location:
- Mac: /Users/Shared/FileMaker/Shared/
- Win: <drive>:\ProgramData\FileMaker\Shared\
Once there, you can open this file in a text editor (I use Visual Studio Code) and edit away.
How do we change the FileMaker default fields?
The defaultFields.xml file provided (and found in the location and placed in the location described above) allows us to make changes to the default fields. Here are some thoughts about it:
- Start by making only a few changes to a field or two. Edit, save and see what happens when you create a new table. Get a feel for how the XML is written.
- There’s a tag in the xml, near the bottom in the <tagList> tag, that identifies one of the fields as the primary key. Make sure that stays there if you plan on using addons in FileMaker 17 or any later version.
- There’s a tag in the xml that identifies each of these fields as utility fields. It is found in the <TagList> tag: “#_FMI_0”. The 0 identifies it as utility. Remove it if you wish, but understand the (small) consequence of doing so (see below).
- As you go to adjust a field’s xml, you can get immediate feedback by creating a new table in a .fmp12 file. If there’s any issue with the xml of a field, such as a missing ” or misspelled tag, that field will not be created. So give it a test.
- If you’d rather not use FileMaker default fields, simply add a blank defaultfields.xml file to that shared location. This action prevents FileMaker default fields from being created.
How will default fields effect my development?
Using the FileMaker default fields can enhance our development in a small, but crucial way: You’ll create a table and immediately begin adding data fields to your system since these utility fields were automatically generated. Additionally, the following points illustrate more benefits:
- We can add other utility fields by adjusting the defaultFields.xml file.
- We can set this defaultFields.xml file up once and be done.
- Every table will have common utility fields which record the basic necessities: primary keys, creation & modification user & timestamp.
- We’ll never have to copy/paste the utility fields from one table to another. One less thing to worry about. I’m sure folks have forgotten to add these at one time or another.
- Since these are utility fields, they do not get added to the layout automatically (as do fields that are created by you during the creation of the table) .
- Utility field-creation is consistent across an entire team.
- A field is identified as the primary key field which is useful for add-ons.
How do I add a certain type of field?
Many folks have asked in the forums how to create a certain kind of field. An amazing tool, by Salvatore Colangelo at Goya, allows you to create the fields you want for each table by constructing the defaultFields.xml file. The FileMaker file actually writes the xml of the fields after we make choices (name, type, primary key, calculation, etc).
Of course you can simply duplicate the xml for a field in the document and adjust it as necessary. By hand. That’s useful too.
But consider a very key point:
Every field in the defaultFields.xml file will be created in every table of every file you work with in FileMaker 17. So if we add a “FirstName” field to our defaultFields.xml file, that field will get created even in the Invoices or Dashboard or Inventory table we create.
Only a few
It seems to me there’s only a few fields that could always be a part of the XML file. We here at Geist Interactive want some fields in every table. Some other developers have more, some less. Here’s ours.
- primaryKey // the primary key of the table. UUIDNumber
- ModificationUser //autoEnter field
- ModificationTimeStamp // autoEnter field
- CreationUser //autoEnter field
- CreationTimeStamp //autoEnter field
- z_One_c // a calculation field that returns a 1. Useful for relationships.
- ModCount // a calculation field that counts the number of times each record has been modified
Remember, these are utility fields, so they server a utility and are not data fields as it pertains to the custom app.
New Feature, New Thinking
The FileMaker Default Fields feature is new to FileMaker 17 and it provides some possible glimpse into the future. We, as developers, can create FileMaker fields using XML, either by hand or using a tool. That’s an interesting thought.
You’re already using them if you’re developing in FileMaker Pro 17 Advanced, so embrace them and make them your own and be happy. They are here to stay.
Also published on Medium.