We have 4 custom fields (Type- Drop-down) where users can select a numeric value.
We want to do calculation based upon the values selected within the dropdown fields and display the results in a scripted field.
Code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField1 = customFieldManager.getCustomFieldObject(10000L)
def customField2 = customFieldManager.getCustomFieldObject(10001L)
def customField3 = customFieldManager.getCustomFieldObject(10002L)
def customField4 = customFieldManager.getCustomFieldObject(10003L)
double calculated
if(issue.getCustomFieldValue(customField1) && issue.getCustomFieldValue(customField2) && issue.getCustomFieldValue(customField3) && issue.getCustomFieldValue(customField4))
{
def cf1= issue.getCustomFieldValue(customField1) as double
def cf2= issue.getCustomFieldValue(customField2) as double
def cf3= issue.getCustomFieldValue(customField3) as double
def cf4= issue.getCustomFieldValue(customField4) as double
return ((cf1+ cf2+ cf3) / cf4)
}
else {
return null
}
Error:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[8]' with class 'java.util.ArrayList' to class 'java.lang.Double'
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.