IssueFactory.getIssue() 使用 id == null 创建问题
IssueFactory.getIssue() creates an issue with id == null
您好,我正在使用 adaptavist scriptrunner 创建一个创建子任务的小脚本:
ApplicationUser user = // .. obtaining the user
MutableIssue parent = // .. obtaining parent issue
MutableIssue child = issueFactory.getIssue()
// ... filling child with some data
// here the errors appear:
// workflow error
Issue subtask = issueManager.createIssueObject(user, child)
// null pointer
subTaskManager.createSubTaskIssueLink(parent, child, user)
我试图找出问题所在,看起来我发现了问题所在:
child.getId() return 为空。我错过了什么?应该 getIssue()
return 没有 id 的空问题吗?
Jira 版本 7.1.7
这应该有效:
- 使用 IssueService.validateSubtaskCreate 验证您的输入参数。
- 使用上一个方法返回的validationResult调用IssueService.create.
- 使用 SubtaskManager.createSubtaskIssueLink 来 link 父任务和子任务问题,就像您已经做的那样。
还有 this related question on Atlassian Answers 有一些示例代码。
MutableIssue child = issueFactory.getIssue()
// issueFactory.getIssue(), returns an instance of MutableIssue,
// that will be used to set issue data, here issue is not yet created
// in jira yet hence issue id and key will be null here
// ...
Issue subtask = issueManager.createIssueObject(user, child)
// issueManager.createIssueObject(user, child), creates the issue
// in the jira and after execution of this statement, you can retrieve
// issue id and issue key
您好,我正在使用 adaptavist scriptrunner 创建一个创建子任务的小脚本:
ApplicationUser user = // .. obtaining the user
MutableIssue parent = // .. obtaining parent issue
MutableIssue child = issueFactory.getIssue()
// ... filling child with some data
// here the errors appear:
// workflow error
Issue subtask = issueManager.createIssueObject(user, child)
// null pointer
subTaskManager.createSubTaskIssueLink(parent, child, user)
我试图找出问题所在,看起来我发现了问题所在:
child.getId() return 为空。我错过了什么?应该 getIssue()
return 没有 id 的空问题吗?
Jira 版本 7.1.7
这应该有效:
- 使用 IssueService.validateSubtaskCreate 验证您的输入参数。
- 使用上一个方法返回的validationResult调用IssueService.create.
- 使用 SubtaskManager.createSubtaskIssueLink 来 link 父任务和子任务问题,就像您已经做的那样。
还有 this related question on Atlassian Answers 有一些示例代码。
MutableIssue child = issueFactory.getIssue()
// issueFactory.getIssue(), returns an instance of MutableIssue,
// that will be used to set issue data, here issue is not yet created
// in jira yet hence issue id and key will be null here
// ...
Issue subtask = issueManager.createIssueObject(user, child)
// issueManager.createIssueObject(user, child), creates the issue
// in the jira and after execution of this statement, you can retrieve
// issue id and issue key