Setting Object Field Defaults
You can use field defaults to set the value of an object field using an Excel™-like formula language. Field defaults calculate the field value based on a formula you create. Literal value defaults enter the exact value in the field. Vault either assigns the default value upon save (formula default) or upon record creation (literal value default). 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.
Vault provides the same formula language, with different options, for lifecycle entry actions and creating custom formula fields for reporting.
Supported Field Types
Object field defaults are available for the following types of fields:
- Object Reference (Set a default referenced object)
- Picklist (Set a default picklist value)
- Status (Set a default status)
The following field types are not supported:
- Any system field other than status
Pre- & Post-Default Expressions
Depending on your default expression, 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 includes literal values or known field values based on a parent or reference relationship (only when a user creates the record from a related list). 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.
- Click the Fields tab.
- Click on a field to open..
- Click Edit.
- To set a formula for a field default, click the Calculator icon. To set a literal value for a field default, enter the value in the Default Value field, and skip to step 8.
- The Edit Formula of Default Value dialog opens. Use the editor to write a formula. See details below.
- Click Validate. Vault will let you know if your expression is valid.
- Click Save.
- Make any other changes to your field.
- Click Save.
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 on your Product object. Requires Yearly Review is a Yes/No field. 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 for Requires Yearly Review.
Using Formulas for Field Defaults
When creating a formula, you can either enter a formula value in the Default Value = field, or use items from the Fields, Functions, and Operators lists to create an expression in the formula field. 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 the Vault CDMS Formula Reference
Guidelines for Field Default Formulas
Your formula must return the type of data required for the field type. For example, a text-type field default formula must return text, and a number-type field a number, etc., otherwise, you cannot save your formula.
Blank Value Handling
If the evaluated expression results in null or blank, Vault does not populate the default value.
Object.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.
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
Empty, required object reference, parent object, and self-referencing object fields that reference single-record objects (single value available for selection) auto-populate when a user creates a new object record, or edits an existing object record. This also applies when an object reference field uses reference constraints, and only a single referenced object record is allowed by those constraints. The field would then default to that single value.