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

0 vote

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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

179 views 0 4
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