script-runner set value in a select list field

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

This widget could not be displayed.
Henning Tietgens Community Champion 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' }

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!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

505 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you