setting list field value in script runner post function

Hi,

I am using Jira 6.2.7. I am trying to set value of a list field using script runner post function. I have tried below code. However option is always returned as null. I do have value 'Jira-Tier1' defined in the list with other values. There are no errors in the log. Thanks for your help!

def optionsManager = componentManager.getComponentInstanceOfType(OptionsManager.class)
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Assignee Group'}

if(cf != null){
def fieldConfig = cf.getRelevantConfig(issue)
def option = ComponentAccessor.optionsManager.getOptions(fieldConfig).find {it.value == 'Jira-Tier1'}
log.debug ("Options is ${option}")
issue.setCustomFieldValue(cf, option)
issue.store()
}

Rama

2 answers

This widget could not be displayed.

You might have a space after "Jira-Tier1" or something...

Thanks Jamie! I did verify the value and also read the value of that field in the script and printed it. I don't see any spaces. Any other pointers?

Appreciate your help!

You should edit the issue using com.atlassian.jira.bc.issue.IssueService#validateUpdate

Hi Jamie,

I would appreciate if you could help me with an example if possible? I am a begineer in this area and struggling a bit to get this working.

Thanks for your help!

Rama

This widget could not be displayed.

Thanks Jamie! I did verify the value and also read the value of that field in the script and printed it. I don't see any spaces. Any other pointers?

Appreciate your help!

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...

533 views 3 19
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