Defining field default values
When creating a new object of a model in the database, you might need to assign a default value for a field if the field value is not provided as input. In some cases, you might also need to calculate the value of a field based on the values of the other fields of the model. To handle these cases, you can use default value expressions.
The default value expression is calculated only when the field in consideration does not have any input value provided. For example, there can be a boolean field called "public" for a user object specifying whether other users can view the user profile information. If a value is not specified for the "public" field when creating a user object, then by default, you can assume that the user profiles are private, and the default value of this field can be set as false.
To specify the default value expression of a field already created via the Designer, you need to Navigate to Models view and select the model and then the field that you would like to specify the default value expression.
You can also specify the default value expression for new fields while adding the new field to a model.
Default value expression can be specified for only the following field types: text, object id, rich-text, email, link, boolean, integer, decimal, date-time, options list, geo point, object reference, basic values list, and file reference.
To define a default value expression in Designer:
- Select f(x). The expression editor will be displayed to access the model fields and built-in functions that you can use in your expressions. Either double click on a model field or function or drag & drop it to the expression text area to add it to your expression.
- Specify your default value expression
- Select OK