Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Access to Cascading field values using Groovy

Michael de Jeu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 5, 2011

Hi,

I'm using a Groovy post function to select a group to assign to an issue to based on the choices in a cascading field. I've got most of the code done but the value that comes back from this part is possibly a map (I think?). I'm not sure how to put this value in an object so that I can pull out the values slelected in field one and field 2. Can anyone shed light on this?

Thanks,

Michael

Code snipet

CustomField cfSysAppSup = cfManager.getCustomFieldObjectByName("System/Application Supported")

Object cfSysAppSupValue = issue.getCustomFieldValue(cfSysAppSup)

Return value

CustomFieldParams: System/Application Supported. Params: {null=[Sales], 1=[Product A]}.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
RamamandA July 28, 2014
It is same as yours. I just changed the issue id. Custom field name is same as yours.
0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2011
RamamandA July 27, 2014

Hi Jamie,

I referenced the link above as I am trying to create a script runner listener to read from cascading select field. I am using Jira 6.2.7 and Script runner 2.1.17. I have created a test project with field name "Cascading Select" and used example provided by you to run in script console. However I am getting below error. Any idea what is wrong in my case? Thanks for your help!!

-Rama

Error

Caused by: javax.script.ScriptException: java.lang.UnsupportedOperationException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111) ... 178 more Caused by: java.lang.UnsupportedOperationException at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:49) at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:82) at com.sun.proxy.$Proxy2888.getAllValues(Unknown Source) at com.atlassian.jira.issue.transport.CollectionParams$getAllValues.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at Script1.run(Script1.groovy:16) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315) ... 179 more
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2014

Can you post your code, or is it identical to mine?

RamamandA July 28, 2014

It is same as yours. I just changed the issue id. Custom field name is same as yours.

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.fields.CustomField


ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

MutableIssue issue = componentManager.getIssueManager().getIssueObject('TP-7')
CustomField cf = customFieldManager.getCustomFieldObjectByName("Cascading Select")
CustomFieldParams cfVal = issue.getCustomFieldValue(cf) as CustomFieldParams

if (cfVal) {
Collection values = cfVal.getAllValues()
String first = values[0]
String second = values[1]

log.debug("First - second: $first - $second")
}
else {
log.debug("Custom field not present on this issue")
}

Andrea Hebert April 24, 2015

Has this been resolved? I am getting the same error on jira 6.3.15

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2015

What error? What's the context?

0 votes
Betsy Walker
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2011

Hi Michael,

Take a look at this forum post: http://forums.atlassian.com/thread.jspa?messageID=257335925

--Betsy

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events