Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Abstract

This code snippet gets the default value of a specific custom field.

...

Code Block
languagegroovy
linenumberstrue
import com.atlassian.jira.component.ComponentAccessor
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 fieldCheckboxes

Examples

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.

References

...