Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Code snippet to get the default value of a custom field

Abstract

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

Logic

Access the custom field by its name, get its relevant configuration for the current issue and then get its default value.

Snippet

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)

Placeholders

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