Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Remove some options(not all) from a select list using groovy

Hi All,

I need to delete some values from a Select List Custom Filed.

I have checked other pages in Community where I found how to delete all the options but that is not my requirement.

I only want to remove some selected options so that all other option Values are untouched and their option Ids are intact.


Kindly help me out here.

Thanks in advance.

1 answer

1 accepted

0 votes
Answer accepted

Had the same problem ("delete all unused option from select list") ..   
after long research I found a solution that works for me:
* loop over all options ( for current Fld-Configuration )
* define JQL-Query -> if option is NOT used ( = JQL.Query-Matches = 0 )
* then remove option ..
* "user" should be admin -> but i'm not sure if necessary ..

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.config.FieldConfig;

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.customfields.option.Option

import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.context.IssueContextImpl;

def getJQLcnt ( String queryString, ApplicationUser user ) { // Returns number of filter-matches
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
SearchProvider searchProvider = ComponentAccessor.getComponent(SearchProvider)
def query = jqlQueryParser.parseQuery(queryString)
SearchResults results =, user, PagerFilter.getUnlimitedFilter())

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getUser() // needed for JQL-Query
CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("BUB Kostenstelle"); // Place your selcet-List custom fieldname
def cft = cf.getCustomFieldType()
Issue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("BBB-540"); // place an issue key that uses that custom field -> to get Context + FldConfiguration
IssueContextImpl issueContext = new com.atlassian.jira.issue.context.IssueContextImpl(issue.getProjectId(), issue.getIssueTypeId());
FieldConfig fieldConfig = cf.getRelevantConfig(issueContext);
OptionsManager optionsManager = ComponentAccessor.getOptionsManager();
List<Option> options = optionsManager.getOptions(fieldConfig);

// String s = ""
for (Option option in options) { // loop on all options
String optVal = option.getValue()
String jqlStr = "'BUB Kostenstelle' = " + optVal // define JQL-Query for Condition
if ( getJQLcnt(jqlStr,user) == 0) // if cond > 0 --> remove option from current CF-Configuration
{ // s = s + " " + optVal
// s

Hi @Peter Weimer

It's been so long when I wanted to use this. But still thanks a lot! It might come in handy in the future.




Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

97 views 0 5
Read article

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