How do I add options to a Select List custom field programatically?

Hi there,

I would like to know how to add default options to a custom select list programatically.

Thanks

4 answers

I wrote a plugin to add/remove/edit customfield values.

The plugin provides a REST API. It works from Jira 6.2+

Hi,

use OptionsManager createOption(FieldConfig fieldConfig, Long parentOptionId, Long sequence, String value)

http://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/issue/customfields/manager/OptionsManager.html

Check thread: https://answers.atlassian.com/questions/16646/how-do-i-programatically-create-and-add-options-to-custom-fields-of-type-select-and-radiobutton

Use search option before asking new question. Add options to select list is so common issue, that it was already answered in the past.

Sorry for repeating the question. Anyway, by using the precious link, I dont know how to set a value in a select field from a plugin. In the example is shown how to create an option but not how to select one of the previously created options.

Any help?

Try use

issue.setCustomFieldValue

and as newValue parameter use on of the options from your select CF. I think, that this solution do not update change history tab. To update history use

customField.updateValue(fieldLayoutItem, issueObject, modifiedValue, changeHolder)

Some links:

https://answers.atlassian.com/questions/22527/how-to-set-a-select-list-type-custom-field-programably

http://forums.atlassian.com/thread.jspa?threadID=46940


I was wondering if there is a way to programatically (REST API or other way) "add/remove/edit" parrent child options within CASCADE Custom Field?!

UPDATE:

The current version of the Custom Field Editor Plugin (1.1+) supports cascading Fields and offers a REST API: https://marketplace.atlassian.com/plugins/jiracustomfieldeditorplugin

Do you have ticket created so I can track this feature?! Thank you.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

108 views 0 2
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you