我正在尝试创建一个发布功能,该功能将在创建问题时创建子任务。 我正在尝试创建一个后置功能,该功能将在创建任务时创建子任务。子任务的数量取决于填充的自定义字段的数量。 现在只有两个字段[14098,14099],但随后它们可能会更多。 吉拉v.6.3.10
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def personFieldsIds = [14098,14099]
for (int personFieldsId:personFieldsIds){
def person = customFieldManager.getCustomFieldObject(personFieldsId)
def personValue = issue.getCustomFieldValue(person)
if (personValue){
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setReporter(issue.reporter)
newSubTask.setAssignee(personValue?.getKey())
newSubTask.setSummary("Subtask for " + personValue?.getDisplayName())
newSubTask.setParentObject(issue)
newSubTask.setProjectObject(issue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{it.getName() == "Sub-task"}.id)
newSubTask.setDescription("Description for " + personValue?.getDisplayName())
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
issueManager.createIssueObject(issue.reporter, newIssueParams)
subTaskManager.createSubTaskIssueLink(issue, newSubTask, issue.reporter)
}
}
错误日志:
2019-05-29 11:30:12,079错误[workflow.ScriptWorkflowFunction]:****************************** ****************************************************** ***** 2019-05-29 11:30:12,096错误[workflow.ScriptWorkflowFunction]:脚本函数在以下问题上失败:null,actionId:1,文件: groovy.lang.MissingPropertyException:否这样的属性:class:Script8的customFieldManager 在Script8.run(Script8.groovy:13)
答案 0 :(得分:0)
问题和图像中的代码以某种方式不相等,并且错误也不适合。
但是,首先,在图像中发布的代码中,实际上您没有属性/变量customFieldManager。获取CustomFieldManager的行丢失。
然后,方法getCustomFieldObject
期望使用long类型的值:https://docs.atlassian.com/software/jira/docs/api/6.3.10/com/atlassian/jira/issue/CustomFieldManager.html#getCustomFieldObject(java.lang.Long)
因此,您可以将其更改为:
def person = customFieldManager.getCustomFieldObject(personFieldsId as Long)
或
def personFieldsIds = [14098L, 14099L]