FileMaker 17 Default Fields

In one of our previous FileMaker 17 videos on YouTube, I touched briefly on the new “Default Fields” functionality introduced in FileMaker 17. In this post, I’ll be diving more into this feature, explaining how it works and how to customize it for your own use.

Prior to FileMaker 17, the standard process of defining fields in a table included creating a new database file, defining a table, then adding fields to the table. You would then copy-and-paste the fields to new tables, or use the initial table as a template and duplicate it to create new tables. In FM17, this process remains, but developers now have the option to customize the default fields added when a table is created, prior to adding a table.

FileMaker 17 comes packaged with a DefaultFields.xml file used to define the default fields when adding a table. The file is located here:

MacOS: /Users/Shared/FileMaker/Shared/DefaultFields.xml
Windows: <drive>:\ProgramData\FileMaker\Shared\DefaultFields.xml

In the xml file, each root element is broken down into child elements which contain the attributes of the field to be defined. For example: <Field name=”MyTextField” dataType=”Text” comment=”This is a text field”/>. A very in-depth description of the elements and attributes has been informally documented in a FileMaker Community forum post.

By default, the DefaultFields.xml file is pre-populated with 5 fields: PrimaryKey, CreationTimestamp, CreatedBy, ModificationTimestamp, and ModifiedBy. Alternatively, a blank DefaultFields.xml file can be placed into the directory mentioned above and no fields will be auto-added when a table is created.

I decided to take this functionality and apply some of the naming standards found at FileMakerStandards.org to create our own DefaultFields.xml file. Below is a small example of the larger demo file attached to this post.

<?xml version=1.0 encoding=UTF-8?>
<FMDefaultItems version=1 source=17.0.1 membercount=1>
<DefaultFields membercount=3>
<Field id=1 name=id_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=OnlyDuringDataEntry allowOverride=False notEmpty=True unique=True existing=False />
<Storage autoIndex=True index=None global=False maxRepetitions=1>
<LanguageReference name=Unicode id=2 />
</Storage>
<TagList primary=True>#_FMI_0</TagList>
</Field>
<!– Creation Defaults –>
<Field id=2 name=creationDate fieldtype=Normal datatype=Date comment=Local Date each record was created>
<AutoEnter type=CreationDate prohibitModification=True />
<Validation type=OnlyDuringDataEntry allowOverride=False notEmpty=True unique=False existing=False>
<Strict>FourDigitYear</Strict>
</Validation>
<Storage autoIndex=True index=None global=False maxRepetitions=1 />
<TagList>#_FMI_0</TagList>
</Field>
<Field id=3 name=creationTime fieldtype=Normal datatype=Time comment=Local time each record was created>
<AutoEnter type=CreationTime prohibitModification=True />
<Validation type=OnlyDuringDataEntry allowOverride=False notEmpty=True unique=False existing=False>
<Strict>Time</Strict>
</Validation>
<Storage autoIndex=True index=None global=False maxRepetitions=1 />
<TagList>#_FMI_0</TagList>
</Field>
</DefaultFields>
</FMDefaultItems>

In the above example, there are 3 fields being created: id_PrimaryKey, creationDate, and creationTime. The field “id_PrimaryKey” (name=”id_PrimaryKey”), is getting assigned the field id of 1 (id=”1″), which is the root ID that FileMaker assigns each field upon creation. Since this field is getting populated with a UUID in the “Calculation” element (![CDATA[Get( UUID )]]), it needs to be a “normal” field (fieldtype=”Normal”) and the datatype is “Text”. The field validation is setup so the field must have a unique, non-empty value (notEmpty=”True” unique=”True”), cannot be overwritten (allowOverride=”False”), and is only validated during data entry (type=”OnlyDuringDataEntry”). The field storage is set to NOT be indexed (index=”None”),  to “Automatically create indexes as needed” (autoIndex=”True”), is NOT a global (global=”False”), and is NOT a repeating field (maxRepetitions=”1″).

The other two fields are creationDate and creationTime, the data types are getting set to “Date” and “Time”, respectively (datatype=”Date” and datatype=”Time”). In the “validation” element, the fields must have a value (notEmpty=”True”), cannot be overwritten (allowOverride=”False”), and are only validated during data entry (type=”OnlyDuringDataEntry”), each with strict data types (<Strict>FourDigitYear</Strict> and <Strict>Time</Strict>).

The sample file includes 15 fields: id_PrimaryKey, creationDate, creationTime, creationAccountName, creationTimestamp, creationHostTimestamp, creationUser, modificationDate, modificationTime, modificationAccountName, modificationTimestamp, modificationHostTimestamp, modificationUser, textName (default text field), and key_ONE (boolean field). Feel free to copy this example, customize it, and create a DefaultFields.xml file of your own.

If you have any questions or would like assistance customizing the DefaultFields.xml into your solution, please contact us.

Leave a Reply

Your email address will not be published. Required fields are marked *