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

script-runner set value in a select list field

William JUTEAU Feb 05, 2014

Hello,

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

1
2
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == '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 ?

Thanks

2 answers

1 accepted

9 votes
Answer accepted
Henning Tietgens Feb 05, 2014

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' }

William JUTEAU Feb 05, 2014

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.

William JUTEAU Feb 10, 2014

Forget it, I didn't set the value :

issue.setCustomFieldValue(cf, value)

thanks :)

Joshua Giffen Jun 09, 2016

This works great!

David Just Mar 09, 2018

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

Joe Del Nano Feb 12, 2019

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

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Join our webinar: “Asset Management: The Role of Context in ITSM” with Atlassian & Riada

  Hi Atlassian Community! This is Teresa from the Jira Service Desk team. On June 19th, I’ll be hosting a webinar “Asset Management: The Role of Context in ITSM” with Atlassian Partne...

186 views 2 3
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