DefaultFields.xml

Document created by Dillik on Aug 3, 2018Last modified by Dillik on Aug 3, 2018
Version 3Show Document
  • View in full screen mode

The DefaultFields.xml file tells FileMaker Pro Advanced which fields to automatically add to newly created tables. This post details a minimal set of instructions your file needs to make FMPA auto-create the fields you want. (For instructions on where this file should reside, see the documentation.)

 

For FMPA to auto-create any fields, the DefaultFields.xml file must conform to the following basic structure:

 

<FMDefaultItems>  
<DefaultFields>  
<Field></Field>  
<Field></Field>  
<Field></Field>  
...  
</DefaultFields>  
</FMDefaultItems>  

 

Notes:

  • HTML-style comments <!-- --> are allowed but must not be placed above the <FMDefaultItems> element.
  • Elements may be given various attributes such as <Field name="My field" dataType="Number"></Field>. Attribute order within a tag is irrelevant.
  • Most attributes are optional; FMPA will use default values if an optional attribute is omitted.
  • In the default copy of this file included in FMPA, the "memberCount" attribute seems intended to describe how many child elements a parent element contains, but FMPA behaves the same even if the value is inaccurate or omitted.
  • Tag names, attribute names, and elements' contents are not case-sensitive, but closing tags must match the case of their opening tags.
  • Self-closing tags such as <Field/> are allowed if the element doesn't have any child elements.

 

Encoding Declaration

It's a good idea to start your document with the following (although FMPA doesn't seem to have a problem when it's missing):

 

<?xml version="1.0" encoding="utf-8"?>  

 

FMDefaultItems

  • This is the outermost element (required).
  • Comments can't be placed above this element, or FMPA will fail to read the document.
  • May use the following attributes (changing or omitting either seems to have no consequence):
  • version (default: "1")
  • source (default: "17.0.1")
  • Closing tag isn't required (though omitting it technically yields an invalid XML file).

 

DefaultFields

FMDefaultItems > DefaultFields

  • This is the only child of FMDefaultItems and is required.
  • Closing tag isn't required (though omitting it technically yields an invalid XML file).

 

Field

FMDefaultItems > DefaultFields > Field

  • Each Field element (child of DefaultFields) represents a field to create.
  • May use the following attributes:
    • name (if omitted, will serialize fields as "<unknown>", "<unknown> 2", etc.; truncated to 100 chars)
    • comment (optional field comment; truncated to 30000 chars)
    • dataType (required; must be one of the following options)
      • "Text"
      • "Number"
      • "Date"
      • "Time"
      • "Timestamp"
      • "Binary" (container)
    • fieldType (optional)
      • "Normal" (default)
      • "Calculated" (turns this field into a calculation field; see "AutoEnter" element below)
      • "Summary" (turns this field into a summary field; see "SummaryInfo" element below)
  • The example file also uses an "id" attribute to serialize each field, but FMPA ignores these values when creating the fields.

 

Example (text field with field comment):

 

<Field name="MyTextField" dataType="Text" comment="This is a text field"/> 

 

Validation

FMDefaultItems > DefaultFields > Field > Validation

  • Optional child of Field (if omitted, no validation applies).
  • May use the following attributes (all optional):
    • type (when to validate)
      • "OnlyDuringDataEntry" (default)
      • "Always"
    • allowOverride (whether the user can override failed validation)
      • "True" (default)
      • "False"
    • notEmpty (whether validation requires a non-empty value)
      • "True"
      • "False" (default)
    • unique (whether validation requires a unique value)
      • "True"
      • "False" (default)
    • existing (whether validation requires an existing value)
      • "True"
      • "False" (default)
  • Validation options are ignored for calculation and summary fields.

 

Example:

 

<Field name="MyUniqueField" dataType="Text">  
<Validation unique="True" allowOverride="False" type="Always"/>  
</Field>  

 

Strict

FMDefaultItems > DefaultFields > Field > Validation > Strict

  • Optional child of Validation (if present, places stricter requirements on a number, date, or time value).
  • Contents may be one of the following:
    • Numeric (numeric only)
    • FourDigitYear (4-digit year date)
    • Time (time of day)
  • Ignored if the option doesn't make sense for the field's data type.

 

Example:

 

<Field name="MyNumericOnlyField" dataType="Number">  
<Validation>  
<Strict>Numeric</Strict>  
</Validation>  
</Field>  

 

Range

FMDefaultItems > DefaultFields > Field > Validation > Range

  • Optional child of Validation (if present, validation requires values to fit in the specified range).
  • If using a range, must use assign both "from" and "to" attributes or the range will be ignored.

 

Example:

 

<Field name="MyLimitedField" dataType="Number">  
<Validation allowOverride="False">  
<Range from="1" to="5"/>  
</Validation>  
</Field>  

 

Calculated

FMDefaultItems > DefaultFields > Field > Validation > Calculated > Calculation > Text

  • Optional child of Validation (if present, validation requires the calculation to evaluate as boolean true).
  • Must contain Calculation element, which must contain Text element (regardless of field's data type), which must contain calculation text wrapped in the following: <![CDATA[ ]]>

 

Example (validation requires value greater than 0):

 

<Field name="MyPositiveNumber" dataType="Number">  
<Validation>  
<Calculated>  
<Calculation>  
<Text>  
<![CDATA[Self > 0]]>  
</Text>  
</Calculation>  
</Calculated>  
</Validation>  
</Field>  

 

Message

FMDefaultItems > DefaultFields > Field > Validation > Message

  • Optional child of Validation (if present, the contents of this element will be used in validation failure dialogs for this field).

 

Example:

 

<Field name="MyLimitedField" dataType="Number">  
<Validation allowOverride="False">  
<Range from="1" to="5"/>  
<Message>Out of range!</Message>  
</Validation>  
</Field>  

 

Storage

FMDefaultItems > DefaultFields > Field > Storage

  • Optional child of Field (if omitted, all storage defaults apply).
  • May use the following attributes (all optional):
    • autoIndex
      • "True" (default; automatically create indexes as needed)
      • "False"
    • index (ignored if field can't be indexed)
      • "None" (default)
      • "Minimal" (see FMPA help; interpreted as "All" if used for a non-text field)
      • "All"
    • global
      • "True" (field is a global field)
      • "False" (default)
    • maxRepetitions (set to number of repetitions; default 1)

 

Example (global field with 2 repetitions):

 

<Field name="MyGlobalField" dataType="Number">  
<Storage global="True" maxRepetitions="2"/>  
</Field>  

 

LanguageReference

FMDefaultItems > DefaultFields > Field > Storage > LanguageReference

  • Optional child of Storage, determines the field's sorting/indexing order (if omitted, uses install language?).
  • May use the following attributes:
    • name (generally corresponds to the value in the "Default Language" popup menu in indexing options, with some exceptions)
    • id (apparently ignored)

 

Example:

 

<Field name="MyUnicodeField" dataType="Text">  
<Storage>  
<LanguageReference name="Unicode"/>  
</Storage>  
</Field>  

 

Furigana

Attributes/elements for Furigana options are unknown at this time.

 

TagList

FMDefaultItems > DefaultFields > Field > TagList

  • Optional child of Field (has no apparent effect, should be safe to omit).
  • Example file uses contents of "#_FMI_0 " (with trailing space, minus quotation marks).
  • May use the following attribute:
    • primary ("True" theoretically denotes a primary key field, but Add-on Tables use their own benchmark for whether a table has a primary key)

 

Example:

 

<Field name="MyKeyField" datatype="Number">  
<TagList primary="True"/>  
</Field>  

 

AutoEnter

FMDefaultItems > DefaultFields > Field > AutoEnter

  • Child of Field.
  • When used in a non-calculation field (i.e. when the field has a fieldType of "Normal" or an unspecified fieldType), this element contains auto-enter options (optional).
  • When used in a calculation field (i.e. when the field has a fieldType of "Calculated"), this element contains the calculation definition (required; see "Calculated" element below).
  • May use the following attributes (most are optional):
    • type
      • "Calculated" (this value is required when defining a calculation field; see "Calculated" element below; not required when defining auto-enter calculations)
      • "SerialNumber" (see "SerialNumber" element below)
      • "ConstantData" (see "ConstantData" element below)
      • "LastVisited"
      • "CreationDate"
      • "CreationTime"
      • "CreationTimestamp"
      • "CreationName" (same as Get(UserName))
      • "CreationAccountName" (same as Get(AccountName))
      • "ModificationDate"
      • "ModificationTime"
      • "ModificationTimestamp"
      • "ModificationName" (same as Get(UserName))
      • "ModificationAccountName" (same as Get(AccountName))
    • lookup fields should be an additional element, but their syntax is unknown at this time
    • overwriteExisting (whether result of auto-enter calculation can overwrite existing values; inverse of "Do not replace existing value" checkbox in UI)
      • "True"
      • "False" (default)
    • alwaysEvaluate (regards auto-enter calculations only; inverse of "Do not evaluate if all referenced fields are empty" checkbox in UI)
      • "True"
      • "False" (default)
    • prohibitModification (ignored for calculation fields, which are always unmodifiable)
      • "True"
      • "False" (default)
  • Even if the AutoEnter element has no "type" attribute assigned, the Calculated element may still define an auto-enter calculation to use.

 

Example (auto-enter account name, can't be modified):

 

<Field name="MyCreationAccount" dataType="Text">  
<AutoEnter type="CreationAccountName" prohibitModification="True"/>  
</Field>  

 

Calculated

FMDefaultItems > DefaultFields > Field > AutoEnter > Calculated > Calculation > Text

  • Child of AutoEnter (see usage above).
  • If this element is used, it must contain a Calculation element, which must contain a Text element (regardless of field's data type), which must contain calculation text wrapped in the following: <![CDATA[ ]]>

 

Example (calculation field, returns the number 1):

 

<Field name="MyNumber1" dataType="Number" fieldType="Calculated">  
<AutoEnter type="Calculated">  
<Calculated>  
<Calculation>  
<Text>  
<![CDATA[1]]>  
</Text>  
</Calculation>  
</Calculated>  
</AutoEnter>  
</Field>  

 

We can make the above example an auto-enter calculation instead of a calculation field by removing the field's "fieldType" attribute (can also remove the AutoEnter's now-optional type of "Calculated"):

 

<Field name="MyNumber1" dataType="Number">  
<AutoEnter>  
<Calculated>  
<Calculation>  
<Text>  
<![CDATA[1]]>  
</Text>  
</Calculation>  
</Calculated>  
</AutoEnter>  
</Field>  

 

SerialNumber

FMDefaultItems > DefaultFields > Field > AutoEnter > SerialNumber

  • Optional child of AutoEnter, only applicable when AutoEnter's type is "SerialNumber".
  • May use the following attributes:
    • nextValue (defaults to 1 if omitted or empty)
    • increment (defaults to 0 if omitted or empty)
  • Interestingly, an increment of 0 is allowed via XML but not via the normal UI. It produces a (useless) serial number field which doesn't increment.

 

Example:

 

<Field name="MyRecordID" dataType="Text">  
<AutoEnter type="SerialNumber">  
<SerialNumber nextValue="R0001" increment="1"/>  
</AutoEnter>  
</Field>  

 

ConstantData

FMDefaultItems > DefaultFields > Field > AutoEnter > ConstantData

  • Optional child of AutoEnter, only applicable when AutoEnter's type is "ConstantData".
  • Element's content is used as the field's auto-enter constant. If element is present but has no contents, the auto-enter constant will be empty (such as when a duplicated record should have an existing value blanked out).

 

Example:

 

<Field name="MyAutoEnter1" dataType="Number">  
<AutoEnter type="ConstantData">  
<ConstantData>1</ConstantData>  
</AutoEnter>  
</Field>  

 

SummaryInfo

FMDefaultItems > DefaultFields > Field > SummaryInfo

  • Child of Field; required if field's fieldType is "Summary".
  • May use the following attributes (all optional):
    • operation (all operations use the field indicated in the SummaryField element, below)
      • "Total" (default)
      • "RunningTotal"
      • "Average"
      • "WeightedAverage" (also requires AdditionalField, below)
      • "Count"
      • "RunningCount"
      • "Minimum"
      • "Maximum"
      • "StdDeviation"
      • "StdDeviationByPopulation"
      • "Fractional"
      • "FractionalSubtotal" (also requires AdditionalField, below)
      • "List"
    • summarizeRepetition
      • "Together" (default)
      • "Individually"
    • restartForEachSortedGroup (not sure how to use; supposed to work with "RunningTotal" type, but that type doesn't seem to support AdditionalField as expected)
      • True
      • False (default)
  • Unlike when using the standard UI, a summary field can be defined here to have a data type which differs from its source field's data type. This works for now, but use differing types at your own risk! (Also, a "List" operation probably isn't useful as anything but text.)

 

SummaryField

FMDefaultItems > DefaultFields > Field > SummaryInfo > SummaryField > FieldReference

  • Required child of SummaryInfo. Must contain a FieldReference element with a "name" attribute referring to the field being summarized.

 

Example (maximum of MyNum):

 

<Field name="MyNum" dataType="Number"/>  
<Field name="MyMaxNum" dataType="Number" fieldType="Summary">  
<SummaryInfo operation="Maximum">  
<SummaryField>  
<FieldReference name="MyNum"/>  
</SummaryField>  
</SummaryInfo>  
</Field>  

 

AdditionalField

FMDefaultItems > DefaultFields > Field > SummaryInfo > SummaryField > FieldReference

  • Child of SummaryInfo; required if using SummaryInfo with an operation of "WeightedAverage" or "FractionalSubtotal" to indicate the additional field the summary should use.
  • May also be used when using a running total which restarts for a sorted group, but this doesn't seem to work as expected.

 

Example (average of MyNum, weighted by MyNum2):

 

<Field name="MyNum" dataType="Number"/>  
<Field name="MyNum2" dataType="Number"/>  
<Field name="MyWeightedAverage" dataType="Number" fieldType="Summary">  
<SummaryInfo operation="WeightedAverage">  
<SummaryField>  
<FieldReference name="MyNum"/>  
</SummaryField>  
<AdditionalField>  
<FieldReference name="MyNum2"/>  
</AdditionalField>  
</SummaryInfo>  
</Field>  
10 people found this helpful

Attachments

    Outcomes