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

0 vote

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

0 vote

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"

0 vote

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?

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

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
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
Posted 7 hours ago in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

31 views 1 2
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