问题陈述:我想设置自定义脚本后置函数,以便在特定工作流程转换时将自定义字段(文本字段)增加+1,例如,当转换从固定状态启动时-将Program、Label和External字段增加+1。
方法:(自定义脚本post函数)
字段已创建:脚本字段(程序、标签和外部)-文本字段
版本:吉拉8.20.6
我正在使用的Groovy脚本引发错误:
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField cf = customFieldManager.getCustomFieldObject("customfield_11727")
Double val = (issue.getCustomFieldValue(cf) as Double)
if ( val == null)
val = 1
else
val = val + 1
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf),val), changeHolder)
从Script Runner主控台取得时发生错误:“* 无法解析类别ComponentManager*”
1条答案
按热度按时间gcuhipw91#
ComponentManager已过时,如Manu Mishra所述
替换为:
与此:
并替换import语句:
至: