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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Delete duplicate custom field options

Hi all!

We have a 7.3.8 Jira Server with some custom fields. One of these has some options created automatically. Unfortunately, in this process there was a mistake and some options were created duplicate.

So now, the options of this custom field are (values are simplify to clarify the problem):

  • Option 1
  • Option 1
  • Option 2
  • Option 2

Is there any possibility of delete duplicate options form a custom field with a script (Script Runner)?

Therefore, the result should be:

  • Option 1
  • Option 2

Is this possbile via script? Has anyone done it before? 

Thank you very much.

1 comment

Hi Miguel,

I understand your problem, but could you clarify the details surrounding your use case? I mean, do you plan to just run this script once? Do you need to fix just one field that has duplicate options or are there multiple fields that have duplicate options? 

I am assuming this is just a custom field of type Select List. If there aren't many duplicate values, can't you simply go to the "Edit" page for the custom field and manually delete the duplicate options without using a script?



Hi Joshua,

Thank you for your response. 

I'll try to clarify the problem:

  • I plan to run this script once, but probably the problem would reproduce in a future.
  • At the moment, I need to fix one field, but in the future could be more than one.
  • Yes, it's a custom field of type Select List and has a a lot of options (thousands), so manually deleting is not an option.

I hope this clarify the scenario.

Thanks in advance ;)



Hi Miguel,

I developed a script to be used in the Script Console to delete duplicate option values for a given Select List Field.

Here are my field options before the script: 

Screen Shot 2017-11-16 at 1.01.53 PM.png


And after running the script:

Screen Shot 2017-11-16 at 1.02.15 PM.png

Here is the script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.customfields.option.Options

def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def field = customFieldManager.getCustomFieldObjectByName("TestField")
IssueContextImpl issueContext = new IssueContextImpl(null, null)
FieldConfig fieldConfig = field.getRelevantConfig(issueContext)
Options options = optionsManager.getOptions(fieldConfig)
def uniqueOptions = []
def optionsClone = options.clone()
for (option in optionsClone) {
if (!uniqueOptions.contains(option.getValue())) {
else {
log.debug("Found duplicate option: " + option.getValue())

Just replace the field name in quotes with your field name and run the script in the Script Console. You may have static type checking errors, but it will still work OK.

Thank you very much Joshua for your response and your effort.

It have been really helpful, so I appreciate your help ;)

However, I have another doubt now. What happens with the duplicated options that are currently related with an issue? For example, If an issue A is related with option "Option 1" (with an imaginary ID 1), and you delete this option becaue exists another option "Option 1" (with ID 2), it is possible to reassign the issue to use "Option 1" with ID 2 (the option that has not been removed).

Thanks a lot!



To be quite frank Miguel, I am not sure what will happen. I suspect you'll end up with a lot of issues that have empty values for that field. Yes, I can see how that would be problematic if you deleted options that issues were actually using. 

You could definitely search through issues and replace their duplicated option with the correct option before running the deletion script. I have a script to search for issues and replace their custom field values.

But how many unique options are there for this field? If you had 10 unique options, this wouldn't take very long. If you have hundreds or thousands of unique options, I'd think this would become very time consuming. 

Hi Joshua,

It would be great if you can share the script that you have mentioned :)

Talking about the unique options, I'm afraid that there are thousands of unique options, and probably, as you said, it could take a long time.




Joshua Yamdogo @ Adaptavist Could you share your code?


Log in or Sign up to comment