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

How to edit an option of a custom field using the option ID using script runner

I am trying to update an option of a select list (based on changes in a certain issue). For example if the Description of "Issue 1" changes from "OptionName" to "Option Name" then the option of the select list custom field should also change to "Option Name".

Is there any way to update an option using the option ID for a particular custom field?

2 answers

Mmm, yes, it seems to be possible...

1) You can get previous Summary field value via

For example:

def changeItems = changeHistoryManager.getAllChangeItems(issue)

if (changeItems) {
def originalResolutionDate = changeItems.findAll {
it.field == "resolution"


2) And update custom field options via There's findByOptionId(Long optionId) method and setValue(Option option, String value) .

3) You can get appropriate field config via


Hope this will help.

Hi Anton, I have tried the above suggestion, however I am unable to use the setValue() method. It is throwing error. 

Error Message:  

 [Static type checking) - Cannot find matching method


java.lang.String). Please check if the declared type is right and if the method


Possible solutions: getClass()  line 22, column 1.


Below is my code for your reference


def issue = event.issue as Issue

OptionsManager optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class);
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def newOptionValue = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "Name").collect {it.toString }.join(", ")
def oldOptionValue = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "Name").collect {it.fromString }.join(", ")

def cf = customFieldManager.getCustomFieldObjectByName("Custom_Field")
def fieldConfig = cf.getRelevantConfig(issue)
Option oldOption = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == oldOptionValue.toString()}

void setValue(oldOption, newOptionValue)

Did you ever get this to work?


What problem are you trying to solve? Could you please provide business-case?

You mean adding new options to select list on the fly? Or just choosing from existing ones?

Hi Anton,

I have to update/rename an option from the set of already existing options. 

We already have a script to add new options in the form of issues (if a certain issue type is created its summary will be automatically be added as option). So if the user updates (changes the summary) the issue, the option should also change.


IssueType: Fruits

Custom field Name: "Select Fruits"

Now if a new issue of type "Fruits" gets created, say for example "Apple" it will get added as an option to the Custom_field "Select Fruits" - this is working. But if someone edits the issue and changes from "Apple" to "Apples" it should Update the option also to "Apples" - this I'm unable to do.

@Praveen  we are also facing the same issue, Did you get solution to this? If yes, can you please help me over here..

I also need to update the existing custom filed option

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events