Field defaults allow organizations to ensure that data is entered correctly for new object records. Field defaults calculate and populate a given field with either a literal value or a formula-calculated value. Literal value defaults enter the exact value in the field.
Some example uses include:
- Setting a default Status or picklist value for an object record.
- Creating default serial numbers by adding one (1) to a Last Used Serial Number field value.
- Creating a formula that evaluates a given field to set a default Yes (expression is true) or No (expression is false) on a field.
- Setting a default field value specific to an object type.
This functionality uses Vault’s formula language with object configuration.
Supported Field Types
Object field defaults are available for the following types of fields:
- Number
- Text
- Yes/No
- Date
- DateTime
- Picklist
- Long Text
- Rich Text
- Object Reference (Set a default referenced object)
- Parent Object (Set a default parent object)
- Status (Set a default status)
The following field types are not supported:
- Lookup
- Name (Configure defaulting for the Name field using System-Managed Object Record Names.)
- Any system-managed field other than Status
Order of Operations for Object Field Defaults
On object record creation, object field default values populate in the following order:
- Object field defaults with a static value
- Values a user enters manually and then saves
- Values set by Vault Java SDK triggers
- Values generated by the Update Record Field action when it occurs on a Create Record event
- Object field defaults with a formula-calculated value
- If the value of the field is currently blank, the object field defaults with a static value
If a field has more than one default value configured, Vault creates the object record with the value that is populated last. For example, if you create a new Product record where the Country field has a static default value of CAN, and the Update Record Field action is configured to set the field to Canada on a Create Record event, the value for Country will be Canada.
The final step in the order of operations sets the static default value only if the field value is blank. This means that if an object record field has a static field default, that field can never default to a blank value. For example, if you create a new Product record where the Country field has a static default value of Canada, and you set the Country field to blank before saving, the value for Country will be Canada after saving. If you need to set a field that has a static default value to blank, you must do so after record creation.
Note that field defaults configured at the object type level override defaults configured at the object level.
Pre- & Post-Default Expressions
Depending on your default expression formula, Vault populates the default field value when a user creates (pre-default) or saves (post-default) an object record.
An expression is pre-default when it:
- Only includes literal values
- Only includes literal values or known field values based on a parent or reference relationship; this can only occur if the relationships is created during the initial record creation, i.e., the record was created from a related record.
Any expression that is not pre-default is a post-default expression.
How to Set a Field Default
To set a field default:
- Open an object from Admin > Configuration > Objects.
- Open the Fields tab and then click into a field.
- Click Edit.
- In the Default Value section, enter a literal value or use items from the Fields, Functions, and Operators tabs to create an expression. See examples for default values, or learn more about functions and operators in the Vault Formula Reference Guide.
- Click Validate. Vault will let you know if your expression syntax is valid.
- Click Save.
If your object uses object types, you can also set field defaults at the object type level. This overrides defaults set at the object level.
Setting Field Defaults on Yes/No Fields
When you configure a field default for a Yes/No-type object field, either with a formula or literal default value, enter true
for Yes and false
for No.
For example, you may have a Requires Yearly Review field (Yes/No) on your Product object. You can configure a field default so that Requires Yearly Review defaults to Yes on all Product records. Enter true
in the Default Value field.
Setting Field Defaults on Parent & Reference Object Fields
When configuring a field default for a parent object or object field, you must provide a single token that refers to another object reference field. The field that you point to may be on any related object.
Example: Reference Object
You may want a newly created Campaign Event record to have the same Product relationship as its parent Marketing Campaign record. To set this up, you’d provide the token that points to the Product field on the related Marketing Campaign record: ${{marketing_campaign__cr.product__c}}
Example: Parent Object
In a CTMS Vault, you may want the Study field (parent object) to default when you create a Clinical User Task record from inside a Monitoring Event record. Because Monitoring Event also has a relationship to the Study object, you can do so. To set this up, you’d use the following token as the default value: ${{monitoring_event__vr.study__v}}
Setting Field Defaults on Picklist Fields
When configuring a default value for a picklist field, you can set a literal value or use the expression builder to set a value based on a formula.
Note: Multi-value picklist fields can only use a literal value default.
Example: Literal Value
If most employees are based in Ohio, you could set a literal value for the Address - State picklist field on the Employee object. For this, you would select the name value from the drop-down:
Ohio
Example: Calculated Value
If your Employee object includes an Office Location field, you could dynamically default the Address - State picklist field based on the Office Location selection:
If(Picklist.office_location__c = 'Dublin OH', Picklist.state__c.ohio__c, null)
Setting Field Defaults on Rich Text Fields
When configuring a default value for a Rich Text field, you must wrap the entire value in double quotes. You can apply text formatting using supported HTML tags and attributes. Download the list of supported HTML tags and attributes here.
For example, if you want the text to appear to users as red with the word “Canada” in bold, you would enter the following value:
"<p style='color:#FF0000'>This site is located in <b>Canada</b>.</p>"
Do not include <body> or <head> tags. Adding these tags to a Rich Text default value will have unexpected results.
Field defaults on Rich Text fields cannot exceed 3,900 characters, including HTML markup and vairable names. If you need more characters, consider adding your content to a field and calling that field in your default value.
Using Formulas for Field Defaults
When creating a formula, you can either type a formula expression into the Default Value = field, or use items from the Fields, Functions, and Operators lists to create the expression. To move an item from these panels to the formula field, double-click on it or click the Arrow button. The formula field operates like a basic text editor.
For details about formula syntax and general guidelines for formulas, see Creating Formulas in Vault.
Data Type
Your formula must return the type of data required for the field type. For example, a default formula for a text-type field must return text and a number-type field must return a number. If your formula returns the wrong data type, validation will fail and you will not be able to save.
Blank Value Handling
If the evaluated expression results in null or blank, Vault does not populate the default value.
Example Formulas
last_used_serial_number__v + 1
This formula adds one (1) to the value in the Last Used Serial Number field. This default value would be useful for incrementing serial numbers for a Product object.
audit_start__c + Days(7)
This formula defaults the Audit End Date field as seven (7) days after the Audit Start Date field. This default value can save users time and ensure consistency during audit planning.
Default Single Value Reference Fields
Vault will automatically populate Object- or Parent Object- type fields if:
- The field is empty.
- The field is required.
- The field references an object where only a single record is available for selection, either because only a single record exists or because of reference constraints.
This defaulting occurs during record creation and when editing an existing record.