This code snippet gets the default value of a specific custom field.
Access the custom field by its name, get its relevant configuration for the current issue and then get its default value.
import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.fields.config.FieldConfig CustomFieldManager customFieldManager = ComponentAccessor.customFieldManager; CustomField customField = customFieldManager.getCustomFieldObjectByName("<Custom field name>") FieldConfig relevantConfig = customField.getRelevantConfig(issue); customField.getCustomFieldType().getDefaultValue(relevantConfig) |
Placeholder | Description | Example |
---|---|---|
<Custom field name> | Name of the custom field | Checkboxes |
The outcome of the code snippet is a String
or an array of Strings (String[])
or an object or a collection of objects which depends on the custom field specified. You could use this code for example to: Set a checkboxes field value to its default value using one of the Set field value post-functions when the default value of the field changes often.
|