Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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