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

script-runner set value in a select list field


I use script runner to create subtask on transition, with additional issues actions like following :

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'GOL Issue Type'}
issue.setCustomFieldValue(cf, 'Foundation data Workbook')

I can't make it work.

'GOL Issue Type' is a select list field, with an option label "Foundation data Workbook"

Can somebody help me to figure this out ?


3 answers

1 accepted

15 votes
Answer accepted

Select lists need an Option object as parameter for setCustomFieldValue(). Use this to find the value for setCustomFieldValue()

import com.atlassian.jira.component.ComponentAccessor

// ...

def fieldConfig = cf.getRelevantConfig(issue)
value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Foundation data Workbook' }

Thanks a lot Henning ! The subtask is now well created but the customfield is not set to the value 'Foundation data Workbook' on the subtask.

Forget it, I didn't set the value :

issue.setCustomFieldValue(cf, value)

thanks :)

This works great!

After searching for 2 days I finally found your answer Henning, and it did the trick for my problem too! Thanks so much!

Great answer:  Worked like a charm for me! Thanks, @Henning Tietgens

Hi All,

Currently it is not working when I create issue. No errors but the customfield is not set to the value.

Any thoughts why it may happen?

Scriptrunner Version:

Jira Version: 8.1.1


But it perfectly works if i set this script to other transition post-function, for example from status 'OPEN' to status 'IN PROGRESS'.

I would appreciate any help!


My script:

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'Department'}
def cfConfig = cf.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find { it.toString() == ' IM Department' }
issue.setCustomFieldValue(cf, value)

Hi All,

I resolved my issue.

So I had to move my post-function to the 1st step before 'Creates the issue originally.'

After that it worked as expected.

This is because in my case script is fetching value from User Properties to apply it to custom field Select List (single choice).

Hello, just adding my 2 cents to this post because I was struggling also.
I'm so newbie at this, I tried with the code in these posts, but ko.

Then I found this adaptavist KB from 2015 :

(just a small mistake, he wrote "selectCf" instead of "cfSelect")

import com.atlassian.jira.component.ComponentAccessor

def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("My Custom Field name")
def cfConfig = cfSelect.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == 'The Value I want to set'
issue.setCustomFieldValue(cfSelect, value)


It works like a charm on Jira 8.8.1 + Scriptrunner 6.7.0 ;-)

I didn't see any error when I run this script but the custom field is not updated.

I think this depends on the position of the custom field update. Currently I use this code to update custom fields:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def fieldLayoutManager = ComponentAccessor.fieldLayoutManager
issue.setCustomFieldValue(customField, newValue)
if ( {
def issueChangeHolder = new DefaultIssueChangeHolder()
def fieldLayout = fieldLayoutManager.getFieldLayout(issue)
def fieldLayoutItem = fieldLayout.getFieldLayoutItem(customField)
def modifiedFields = issue.getModifiedFields()
def modifiedValue = modifiedFields.get(
customField.updateValue(fieldLayoutItem, issue, modifiedValue, issueChangeHolder)

If the issue id exists (that is after the issue was actually created), you have to use customField.updateValue().

Thanks @Henning Tietgens 
The following script worked for me. 


IssueService issueService = ComponentAccessor.getComponent(IssueService);

def optionsManager = ComponentAccessor.getComponent(OptionsManager);
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()

def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def issueObject = issueService.getIssue(user, issue.toString())?.issue

def customField = customFieldManager.getCustomFieldObjectByName("Release Onboarding Status")

Options options = optionsManager.getOptions(customField.getConfigurationSchemes().first().getOneAndOnlyConfig());

def selectedOptions = options.findAll {
it.value == "Not Requested"
}.collect {

// Setting none will work if it can't find an option
issueInputParameters.addCustomFieldValue(, *selectedOptions)

def update = issueService.validateUpdate(user,, issueInputParameters)
if (update.isValid()) {
issueService.update(user, update)


Hello - Is anyone else running into the default becoming permanent?

Both these scripts set the default, but then the field section can not be changes. 


Example 1 -

Example 2-

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

369 views 0 7
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