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.
- Setting a default User record for a User object reference field.
This functionality uses Vault’s formula language with object configuration.
Note: Field defaults for object reference fields do not support the RecordByLabel()
function.
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
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 an object or parent object reference relationship; this can only occur if the relationship is predetermined during the initial record creation. For example, when a child record is created from a parent 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.
- Optional: Use the Records tab on object and parent object reference fields to build a formula that sets a single record as the default value. You can also click the {…} icon to select a field from an object relationship that references the same object.
- 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 Object & Parent Object Reference Fields
When configuring a field default based on an object or parent object field, you can provide a single token that refers to another object reference field. The field that you point to may be on any related object. You can use the {…} icon in the formula editor to browse object relationships and select an object field that references the same object. Up to three (3) levels of outbound relationships are supported.
You can also use the RecordByUniqueField()
function to set any single record as the default field value. You can click the Records tab in the formula editor to use a dialog to build this formula instead of typing it manually. This function requires you to provide a unique field and record on the referenced 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. Since 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
If the default value is invalid, such as an inactive record, Vault does not apply the pre-default expressions. Invalid default values in post-default expressions return an error. The RecordByUniqueField()
function can filter out inactive records and does not apply the post-default value if no active record is found. If the defaulted field contains a dynamic reference constraint, RecordByUniqueField()
can still return an error if a invalid record is returned.
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(office_location_c = 'dublin_ohc', Picklist.statec.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 variable 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. You can use the Records tab on parent object and object reference fields to create a default expression that uses a unique field and record on the referenced object. 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.