Jira scriptrunner脚本字段:在自定义字段上,计算其他自定义字段的值并显示总计

时间:2018-03-09 01:44:30

标签: groovy jira

我正在尝试创建一个自定义字段,显示其他4个自定义字段的计算值。

我需要获取字段,获取值,将值更改为整数(它们是单个选择字段),然后计算字段值。

以下是我的代码:

import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue


def bvField = ComponentAccessor().getCustomFieldManager().getCustomfFieldObjectbyName("BV")
def bvValue = issue.getCustomFieldValue(bvfield)
def tcField = ComponentAccessor().getCustomFieldManager().getCustomfFieldObjectbyName("TC")
def tcValue = issue.getCustomFieldValue(tcField)
def rrField = ComponentAccessor().getCustomFieldManager().getCustomfFieldObjectbyName("RR")
def rrValue = issue.getCustomFieldValue(rrField)
def jobSizeField = ComponentAccessor().getCustomFieldManager().getCustomfFieldObjectbyName("Job Size Field")
def jobSizeValue = issue.getCustomFieldValue(jobSizeField)

def jobSizeInt = Integer.parseInt(jobSizeValue)
def rrInt = Integer.parseInt(rrValue)
def tcInt = Integer.parseInt(tcValue)
def bvInt = Integer.parseInt(bvValue)

def total = (bvInt + tcInt + rrInt) / jobSizeInt


if (bvValue!="none" && tcValue!="none" && rrValue!="none" && jobSizeValue!="none") {
    return total
    } else {
    return 85
}

1 个答案:

答案 0 :(得分:0)

替换

def jobSizeInt = Integer.parseInt(jobSizeValue)
def rrInt = Integer.parseInt(rrValue)
def tcInt = Integer.parseInt(tcValue)
def bvInt = Integer.parseInt(bvValue)

def jobSizeInt = jobSizeValue.toInteger()
def rrInt = rrValue.toInteger()
def tcInt = tcValue.toInteger()
def bvInt = bvValue.toInteger()