Specify a default field value
A default value populates a value in a field when a new record is created.
Avant de commencer
Pourquoi et quand exécuter cette tâche
The default value populates the field on the blank form for a new record, and also subsequently when the new record is submitted if the field is empty. Default values can be specified as either a constant or generated through script.
Procédure
Default field value examples
Review the following examples about specifying default field values.
Constant default values
Javascript default values
To view out-of-box examples of JavaScript default values, navigate to and enter this filter: [Default value] [starts with] [javascript]. Open some of the records and view the default value javascript entries.
Set a default value for assignment_group
javascript:GetIDValue('sys_user_group', 'Development');Set a default value for assigned_to if user has the itil role
- Column label: Assigned to
- Column name: [assigned_to]
- Reference Specification section
- Reference: User [sys_user]
- Reference qual condition: [Roles] [is] [itil]
- Default value script:
javascript:if (gs.hasRole("itil"))current.assigned_to = gs.getUserID();
Set a default value for a duration field
javascript:current.duration_field.setDisplayValue('3 04:30:14');Avoid hard-coding a particular date-time. If the system date-time format changes, the value becomes invalid. Instead, select the Use dynamic default check box and assign a dynamic filter option. For more information on dynamic filters, see Create a dynamic filter option .