Not able to get the value of a custom field using Groovy Script.

I made a custom field whose value am polpulating from a csv file which I have uploaded from jira console. I configured that field on jira screen and able to see the options there. Now I am trying to get the checked values in my groovy script & using the below code for that:

ComponentManager componentManager = ComponentManager.getInstance();

CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();

CustomField svnPathcustomField = customFieldManager.getCustomFieldObject("customfield_12681");

log.error("svnPathcustomField -->"+svnPathcustomField);

String[] svnPath = (String[]) issue.getCustomFieldValue(svnPathcustomField);

log.error("svnPath -->"+svnPath);

In logs the value of "svnPath" is coming null... Please help.

Thanks.

5 answers

1 accepted

This widget could not be displayed.

> The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: o for class: Script24

What's this...? Where is "o" in your code? Can you paste the full script somewhere.

Are you sure the field has options selected?

Hey thanks Jamie :) .. by mistake i have added '0' and now m getting the values...

This widget could not be displayed.

You should be getting an error not null - you can't cast a collection of Option objects to a String[] - I think. Remove the cast and static typing and just log the return value:

def svnPath = issue.getCustomFieldValue(svnPathcustomField)
log.warn "svnPath: $svnPath"

This widget could not be displayed.

What type of field is it?

Does the issue definitely have a value for that field?

What context is the script running in, eg post-function?

This widget could not be displayed.

Field is of type "Multi check box". And I am using script in validation part and trying to get the value in that script.

This widget could not be displayed.

Tried this but again got the value as "null".. :( below is the error on console -

2013-02-13 10:09:28,757 ajp-bio-8009-exec-110 ERROR 502005038 609x16122x1 z4rdb 3.209.125.241 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] svnPath: null

2013-02-13 10:09:28,781 ajp-bio-8009-exec-110 ERROR 502005038 609x16122x1 z4rdb 3.209.125.241 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: o for class: Script24

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

59 views 6 6
Join discussion

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