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

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

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"

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
Community showcase
Published yesterday in Jira Service Desk

Frequently Asked Questions for Jira Service Desk (AKA JSD FAQ)

Just the FAQs! Welcome to the Community, and this Focused-FAQ! Here, we've pulled together some of the most frequently asked questions associated with Jira Service Desk (JSD). We hope ...

50 views 0 6
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