How to get unused the options of custom field

Hi All,

I want to find which options of one custom field are not used by issues , and i get one function is like "issue Object getCustomFieldValue(CustomField customField)", Do we have any other way to fetch the unused options besides to search in all issues ?

1 answer

1 accepted

You would have to loop through the options and for each option you can get the list of issues having this option value using this method

http://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/issue/customfields/impl/MultiSelectCFType.html#getIssueIdsWithValue(com.atlassian.jira.issue.fields.CustomField,%20com.atlassian.jira.issue.customfields.option.Option)

This could be faster than looping through the issues and calling getCustomFieldValue if you don't have so many options but a large number of issues

thanks for your information .

Hi Dieter, I'm wondering how to create a MultipleSettableCustomFieldType Object to call the mothod "getIssueIdsWithValue", when i use

MultipleSettableCustomFieldType mc = (MultipleSettableCustomFieldType)ComponentManager.getComponentInstanceOfType(MultipleSettableCustomFieldType.class);

for(Option op : opt)
{
  if (mc.getIssueIdsWithValue(cf,op).isEmpty())
   unusedOpt.add(op);		   
}

"mc.getIssueIdsWithValue(cf,op).isEmpty() " will cause a java.lang.NullPointerException. Thanks .


I've found the solution like this :

CustomField cf = getCustomField();

CustomFieldType cft = cf.getCustomFieldType();

final MultipleSettableCustomFieldType mc = (MultipleSettableCustomFieldType) cft;

anyway .thanks very much .

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 8 hours ago in Off-topic

Get to know our Atlassian User Group Leaders from Bengaluru, India

Meet @Dinesh Dhinakaran, @Vishnu Vasudeva, @Rajeev Verma, and Jamshid Nalakath: Our extraordinary AUG leaders from Bengaluru, India. These four work together to strengthen the bonds of their local co...

82 views 0 4
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