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:
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.
'<![CDATA[Get( UUID )]]>#_FMI_0'<!-- Creation Defaults -->'FourDigitYear#_FMI_0'Time#_FMI_0
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.