FileMaker 17 + Default Fields… Control Your Own Destiny
If you create a new table in a FileMaker 17 file, you might notice that a few fields were created automatically for you:
Previous versions of FileMaker created no new fields for you. It was up to you to add them yourself, and if you had a standard set of fields that you used for every table, you had to take a trip to a different table and copy / paste them into your new table (or just enter them in by hand and risk missing something important). Now with FileMaker 17, you can make that process automatic… all it takes is an XML file in the right place on your hard drive.
Let’s say you like starting out with a completely blank slate, and want this behavior changed back to pre-FileMaker 17 days. All you need to do is create a blank text file named DefaultFields.xml
(or download + unzip this file) and save it to:
/Users/Shared/FileMaker/Shared/
(macOS)
<drive>:\ProgramData\FileMaker\Shared\
(Windows; you may have to create the 'Shared' folder)
One of the great things about this is that changes to this file go into effect immediately; no having to quit / re-open FileMaker… and you don’t even have to close Manage Database. You can tweak the settings in the XML file and try them out immediately by creating a new table in FileMaker.
Going back to blank fields is not very interesting or helpful, though. Let’s look at the default fields that FileMaker 17 creates:
- PrimaryKey
- CreationTimestamp
- CreatedBy
- ModificationTimestamp
- ModifiedBy
These are all great fields that should belong in every table. In the absence of the DefaultFields.xml
file described above, FileMaker 17 pulls default field details from these locations:
Applications/FileMaker Pro 17 Advanced/FileMaker Pro Advanced.app/Contents/Resources/en.lproj/DefaultFields.xml
(macOS)
<drive>:\Program Files\FileMaker\FileMaker Pro 17 Advanced\Extensions\English
(Windows)
We are going to locate this file and copy the XML code out to use as a base going forward. Follow the animation below to get to this file on macOS:
Click to Expand: Full Contents of DefaultFields.xml
<?xml version="1.0" encoding="utf-8"?>
<FMDefaultItems version="1" source="17.0.1" membercount="1">
<DefaultFields membercount="5">
<Field id="1" name="PrimaryKey" fieldtype="Normal" datatype="Text" comment="Unique identifier of each record in this table">
<AutoEnter type="Calculated" prohibitModification="True" overwriteExisting="True" alwaysEvaluate="False">
<Calculated>
<Calculation>
<Text><![CDATA[Get( UUID )]]></Text>
</Calculation>
</Calculated>
</AutoEnter>
<Validation type="Always" allowOverride="False" notEmpty="True" unique="True" existing="False"></Validation>
<Storage autoIndex="True" index="None" global="False" maxRepetitions="1">
<LanguageReference name="Unicode" id="2"></LanguageReference>
</Storage>
<TagList primary="True">#_FMI_0 </TagList>
</Field>
<Field id="2" name="CreationTimestamp" fieldtype="Normal" datatype="Timestamp" comment="Date and time each record was created">
<AutoEnter type="CreationTimestamp" prohibitModification="True"></AutoEnter>
<Validation type="Always" allowOverride="False" notEmpty="True" unique="False" existing="False">
<Strict>FourDigitYear</Strict>
</Validation>
<Storage autoIndex="True" index="None" global="False" maxRepetitions="1"></Storage>
<TagList>#_FMI_0 </TagList>
</Field>
<Field id="3" name="CreatedBy" fieldtype="Normal" datatype="Text" comment="Account name of the user who created each record">
<AutoEnter type="CreationAccountName" prohibitModification="True"></AutoEnter>
<Validation type="Always" allowOverride="False" notEmpty="True" unique="False" existing="False"></Validation>
<Storage autoIndex="True" index="None" global="False" maxRepetitions="1"></Storage>
<TagList>#_FMI_0 </TagList>
</Field>
<Field id="4" name="ModificationTimestamp" fieldtype="Normal" datatype="Timestamp" comment="Date and time each record was last modified">
<AutoEnter type="ModificationTimestamp" prohibitModification="True"></AutoEnter>
<Validation type="Always" allowOverride="False" notEmpty="True" unique="False" existing="False">
<Strict>FourDigitYear</Strict>
</Validation>
<Storage autoIndex="True" index="None" global="False" maxRepetitions="1"></Storage>
<TagList>#_FMI_0 </TagList>
</Field>
<Field id="5" name="ModifiedBy" fieldtype="Normal" datatype="Text" comment="Account name of the user who last modified each record">
<AutoEnter type="ModificationAccountName" prohibitModification="True"></AutoEnter>
<Validation type="Always" allowOverride="False" notEmpty="True" unique="False" existing="False"></Validation>
<Storage autoIndex="True" index="None" global="False" maxRepetitions="1"></Storage>
<TagList>#_FMI_0 </TagList>
</Field>
</DefaultFields>
</FMDefaultItems>
As we can see, there are a lot of XML elements, tags, and other angry things. There does not seem to be any documentation that describes what FileMaker expects from this file, but we can garner some understanding from the above, as well as the generated XML created from a Database Design Report (DDR). There are differences that need to be addressed to make things work nicely. For example…
If you want to auto-generate a calculated field (such as a field always equalling “1”, often used in conditional relationship joins), you might get XML code from the DDR that looks like:
<Field id="7" dataType="Number" fieldType="Calculated" name="Constant1_c">
<Calculation table="Untitled"><![CDATA[1]]></Calculation>
<DisplayCalculation>
<Chunk type="NoRef">1</Chunk>
</DisplayCalculation>
<Comment/>
<AutoEnter alwaysEvaluate="False"/>
<Storage storeCalculationResults="True" autoIndex="True" index="None" indexLanguage="English" global="False" maxRepetition="1"/>
</Field>
If you were to simply paste this into your DefaultFields.xml
file (into the DefaultFields
sub-child element), it wouldn't work… at least not fully. The calculation would be missing the "1" (it'd simply be blank). But if we change the <Calculation>
element to:
<Calculation><Text><![CDATA[1]]></Text></Calculation>
… it works!
I won’t detail all of my XML findings in setting up a DefaultFields.xml
file for our team at LuminFire, but you can download it for the low, low price of your personal information. ;) Here are our standard fields (note UTC timestamp support!):