Hi All,
I'm getting below error while capturing a value from custom field,
CustomField cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Deployments this week"); Option cf1Value=null; cf1Value=(Option)issue.getCustomFieldValue(cf1, 1 as Double); log.warn (cf1Value);
Error,
Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl, java.lang.Double) values: [Deployments this week, 1.0] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111) ... 144 more Caused by: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl, java.lang.Double) values: [Deployments this week, 1.0] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object) 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.AbstractCallSite.call(AbstractCallSite.java:120) at Script15.run(Script15.groovy:33) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315)
Also try with,
CustomField cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Deployments this week"); Option cf1Value=null; cf1Value=(Option)issue.getCustomFieldValue(cf1); log.warn (cf1Value);
Error,
Caused by: javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '0.0' with class 'java.lang.Double' to class 'com.atlassian.jira.issue.customfields.option.Option' at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111) ... 144 more Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '0.0' with class 'java.lang.Double' to class 'com.atlassian.jira.issue.customfields.option.Option' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599) at Script10.run(Script10.groovy:33) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315) ... 145 more
Any suggestions?
Thanks,
Sanu P Soman
The second version of the script is okay as you call the right method, but you're casting to Option while the method returns Double. What is the type of this custom field ?
custom field is number field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why then are you casting to Option ? Just change the code like that:
Double cf1Value=null; cf1Value=(Double)issue.getCustomFieldValue(cf1);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot:)
Now value is "1.0" - Could you please tell me how I can remove ".0" from the value? (ie, want to skip the decimal part while capturing the value)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try trunc method:
cf1Value.trunc()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.