Want to add one script field with below code. I am trying to achive division of custom filed with a number and output should store in my script field.
i have custom field A in my jira. Want to create Script field 'B'. B will store result of 'A'/1848.
Code:
import com.atlassian.jira.component.componentAccessor
import com.atlassian.jira.issue.Issue
def customFieldManager = componentAccessor.customFieldManager
def Benefits_EstCFID = 54700
def Benefits_EstCF = customFieldManager.getcustomFieldobject(Benefits_EstCFID)
if (!Benefits_EstCF) {
log.debug ("custom field with ID" + Benefits_EstCFID + "not found")
return null
}
def Benefits_Est = issue.getcustomFieldvalue(Benefits_EstCF)
return Benefits_Est/1848
Jira is giving result. But also failing the health condition on each execution at last line where i am dividing 'A' /1848
My guess is that the field is not of the type you are guessing it is, so Benefits_Est does not contain what you expect it to.
Thanks for the reply. Benefits_Est is number type custom filed in our jira.
Script field which i am adding is also number type.
Script field(number type) = Benefits_Est (number type)/1848.
This is what i want to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When i create single jira issue for testing it worked. When i create multiple issues, it failing again. When we check logs, i see below
Logs:
[customfield.Groovycustomfield]: script field failed on issue: ABC-1675, field: Benefit_Est
org.codehaus.groovy.runtime.typehandling.GroovycastException: cannot cast object 'null' with class 'null' to class 'double'. Try 'java.lang.double' instead
at script6.run(Script6.groovy:16)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suspect the custom field you are reading from is empty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
calculation is happening and returning the division value in jira. But the problem is , Health condition is failing. it impacting server performance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't understand what you mean by "health condition"
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.