Overview
The following section describes the default value field property and how to add a default value to a field when designing a Form.
Default values are preset values that automatically appear in a field when creating a new record. Default values can streamline data entry and increase the quality of data by automating the data entry process. This increases consistency and saves time for users.
Behaviour
-
Defining a default value for a field means that the defined default value will automatically be populated in that field when adding a new record.
-
Default values are only generated when adding a new record. Default values are not generated when editing an existing record.
-
If you are using the importer to add a new record and you have not provided a value in a field that has a default value set, then the record will be added with that field left blank.
-
There are two ways to define a default value for a field:
-
Assigning an explicit value which is a single value that you specify. This is useful when there is only value that you expect.
-
Using a formula to automatically generate a calculated value. This is useful when the expected value can vary depending on the context (for example, values that depend on values entered in other fields).
Formulas used in default values are evaluated once, only when a record is added to the Form. They are not re-evaluated when an existing record is edited. If you need the formula to be re-evaluated when updates are made to a record, use a Calculated field instead.
Supported field types:
- Text
- Multi-Line Text
- Quantity
- Single selection
- Multiple selection
- Reference
- Geographic point
- Date
- Week
- Fortnight
- Month
- User
Defining the default value
Entering an explicit default value
Before you start
- Make sure you have already added a database and
- You have been assigned to a role that allows you to add a form
- If not, you can add a new database.
To enter an explicit default value to a field:
- Navigate to the Form Design page.
- Click on any supported field for which default field values can be added.
- Default field value for Text fields
- Default field value for Single select field
-
Default field value for Multi-select field
-
-
Default field value for Reference field
- Default field value for Geographic point
- In this case of a quantity field, assuming you have a "Number of Items" field, and you want new records to default to a specific quantity, such as 10. Select the "Quantity" field from the Fields palette.
- Fill in the properties of the quantity field.
- Choose the option “from Value” to provide an explicit value.
- This will display a box for the default value. Provide the value ,for example, “10”.
- Click "Done" and then "Save".
- The default value is now defined for the field.
- When users add new records, the quantity field will be pre-filled with the default value of 10.
Using formulas to generate the default value
- To use a formula, click on the field or in this case, a quantity field.
- Fill in the properties of the quantity field.
- Choose the option “from Formula” to provide a formula that would return a value automatically.
- In the Formula section add the expression for your Formula. Use the codes you assigned to the fields you need.
- Make sure you Formula is verified. A verified Formula will be marked with green. A Formula that is not correct will be marked with red.
- Click on "Done" to add the field to the Form.
Take a look at all the available Formulas in the Formulas Manual and learn more about writing a formula in the context of a record.
- Click "Done" and then "Save".
- Alternatively click on "Formula editor" in the Formula section to navigate to the Formula editor.
- The Formula editor provides you with a list of all available Functions and all available fields.
- Enter your Formula in the Formula editor. Click on a field to directly select it. If you haven't assigned a code to it, the label will appear .
- If you enter an invalid Formula you will get a warning.
- Click "Done" and then "Save".
The following field types do not support default value formulas:
- Geopoint
- Week
- Fortnight
- Month
- Single selection
- Multiple selection
- Reference
- User
Setting fields with default values as read-only
- Setting fields that have default values defined as read-only means that the value provided as a default for a field cannot be manually edited by users when adding a new record and when editing an existing record. The field remains static with its default value, and users can't override it or input a different value.
- You might choose to set a field with default values as read-only in situations where the value must remain constant over time. For example, you might set as read-only fields that collect the date a record was added or the user who added the record to a form. In these cases, setting the field as read-only preserves the integrity of key information about the addition of the record.
- To make the date field dynamic, allowing users to add records on different dates, you can utilize a formula with the TODAY function. The use of “read-only” ensures that the value remains the same and cannot be updated.
- Setting default values as read-only provides a way to enforce data consistency, accuracy, and control in your database by ensuring certain field values remain unchanged throughout the record's lifecycle.
When using the importer to add or edit records, fields that have been set to read-only will not be updated with the corresponding values from the imported file.
Examples
Capturing the date a record was added
If you need to report on the date a record was added to a Form, say for accountability reasons, you might want to set a default value for a “Date record added” field. If you expect that records will be added on different dates, you can generate the default value using a formula with the TODAY function to dynamically populate the current date when the record is added. You would then set the field as read-only to ensure that users would not be able to modify the date in the future.
Defining the first stage of a workflow as the default value
If you follow a review workflow where records must go through various stages of review, you might choose to add a “Review status” field in your Form. You might then want to set the default value of this field to “Pending review” so that the first stage in your review workflow is automatically set when the record is first added to the Form. Setting a default value for this field will help to streamline the data entry process and ensure that all new records are consistently assigned to the correct stage.
You would not set this field as read-only. As the record progresses through the workflow, users can then edit the record and update the value to reflect the current stage.