How do I get all options from a CustomField select list?


I'm trying to get all Values available from a CustomField of the type select List.
I need this for a ValuesGenerator in my Report-Plugin.

I tried :

CustomField division = cfManager.getCustomFieldObjectByName("Division");
		Options opt = division.getOptions(null, jcn);


CustomField division = cfManager.getCustomFieldObjectByName("Division");

and then I tried to handle the PropertySet.
However I'm not even sure PropertySet or Option is what I need, somehow I don't quite grasp what the api is trying to tell me. =(

Any help?

Thanks in advance =)

2 answers

1 accepted

try with this code

CustomField division = cfManager.getCustomFieldObjectByName("Division");
IssueContextImpl issueContext = new IssueContextImpl(issue.getProjectObject(), issue.getIssueTypeObject());
FieldConfig fieldConfig = division.getRelevantConfig(issueContext);
OptionsManager optionsManager = (OptionsManager) ComponentManager.getComponentInstanceOfType(OptionsManager.class);
Options op=optionsManager.getOptions(fieldConfig);

This actually did the Trick! Yay! Thank you so much.
I have to be through with this till wednesday, you saved me^^

I used some random Issue... I hope that's giong to work for everything^^


No, it won't. You'll only get the list of options for the field context for that issue. For example, if your field has options aa, bb, cc in project WRT and dd, ee, ff in project TRW, then you'll only get half the options listed, because using WRT-1 as your random issue means you get the context which contains only aa, bb and cc.

It will work fine if your field context is global though.

0 vote

I use the code in your first block, but it's more complex than that, because you need to look at the field's context (a single field can have many different option lists).

Rather than try to explain it on long-winded English, there's code below. It assumes you're working with an issue and a custom field. I'm not sure how you'd get to the field context stuff directly without an issue, but this should get you part of the way there:

OptionsManager optionsManager = ManagerFactory.getOptionsManager();
CustomFieldManager cfm = ManagerFactory.getCustomFieldManager();

FieldConfig config = cf.getRelevantConfig(issue);
Options options = optionsManager.getOptions(config);
List<Option> optionList = options.getRootOptions();

for (Option foundOption : optionList) {
            //do something with the foundoption

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 Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

499 views 6 11
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