I am writing a post function to set the value of one customfield based on the value of another. Whenever I access issue.getCustomFieldValue(<some custom field>) , I get an exception.
I am running this post function on the "Create Issue" transition.
Code
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.util.IssueChangeHolder import com.atlassian.jira.issue.ModifiedValue import org.apache.log4j.Category import com.atlassian.jira.issue.customfields.option.Option def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") log.setLevel(org.apache.log4j.Level.DEBUG) ComponentManager componentManager = ComponentManager.getInstance() CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() IssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); log.debug "getting cfType" CustomField cfType = customFieldManager.getCustomFieldObject("customfield_12600") // also tried this with 'def cfValue' Option cfValue = null; if (null != cfType) { log.debug "got cfType with name=" + cfType.getFieldName() cfValue = (Option) issue.getCustomFieldValue(cfType) log.debug "cfValue='" + cfValue + "'" } else { log.debug "got null cfType" }
Log Output
2014-07-22 12:33:55,035 http-bio-8080-exec-24 DEBUG bills 753x10883x1 1mhixyo 207.66.231.212,207.246.140.233 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.PostFunction] getting cfType 2014-07-22 12:33:55,035 http-bio-8080-exec-24 DEBUG bills 753x10883x1 1mhixyo 207.66.231.212,207.246.140.233 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.PostFunction] got cfType with name=Urgency 2014-07-22 12:33:55,037 http-bio-8080-exec-24 WARN bills 753x10883x1 1mhixyo 207.66.231.212,207.246.140.233 /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.SetFieldValueFunction] Error while executing SetFieldValueFunction: groovy.lang.MissingMethodException: No signature of method: com.innovalog.jmwe.IssueProxy.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl) values: [Urgency] groovy.lang.MissingMethodException: No signature of method: com.innovalog.jmwe.IssueProxy.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl) values: [Urgency] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at Script1.run(Script1.groovy:24) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:556) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:527)
It's clear that the CustomField (it's radio-button valued) is getting fetched, but I can never access its value.
Can you provide help?
Bill
to get a field value use only "issue.get("CF")". To use the originally JIRA issue (com.atlassian.jira.issue.Issue), use "issue.issueObject"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I meant to post that on another question but I guess it's still relevant.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would tag the question with that plugin's tag. Plugin owners usually will set up alerts, but only for questions with the right tags.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I appreciate the response, Jamie . My organization does use Jira Misc Workflows. I'm not the sole user/workflow in this environment, so removing this isn't an option.
Still looking for an answer to this question that will be compatible with Jira Misc Workflows.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> jmwe.plugins.functions.SetFieldValueFunction
That's the jira misc workflows plugin. I think it also supports running groovy scripts or something, I've never looked to be honest. Stick with the original and the best.
So maybe you have an error in another function, not this one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I run my existing script in the ScriptRunner console with one slight modification to create the issue context
issue = componentManager.getIssueManager().getIssueObject("PSUP-2506")
This script runs successfully, fetches the value of the custom field, and does not throw an exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.