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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

128 views 0 5
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