Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How do I programatically add options to custom fields of type select?

This was already posted in 2011 here:

It took me quite a bit to get it running with Jira version 7.13.8.

Hope this helps someone

Here is the code:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.customfields.manager.*
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.customfields.option.*
import com.atlassian.jira.issue.fields.config.*

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_29100")
addOptionToCustomField(cField, "the new option")

private OptionsManager getOptionsManager() {
OptionsManager optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class);
return optionsManager;

public Option addOptionToCustomField(CustomField customField, String value) {
Option newOption = null;

if (customField != null) {
final List<FieldConfigScheme> schemes = customField.getConfigurationSchemes();
if (schemes != null && !schemes.isEmpty()) {
FieldConfigScheme sc = schemes.get(0);
Map configs = sc.getConfigsByConfig();
if (configs != null && !configs.isEmpty()) {
FieldConfig config = (FieldConfig) configs.keySet()

OptionsManager optionsManager = getOptionsManager();
Options l = optionsManager.getOptions(config);
Option opt;

newOption = optionsManager.createOption(config, null,
new Long(0), value);

return newOption;




Log in or Sign up to comment

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you