Search code examples
javagroovyjirajira-plugin

IssueFactory.getIssue() creates an issue with id == null


Hi I was using adaptavist scriptrunner to create a small script that creates a subtask:

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)

I was trying to figure out what's wrong, and looks like I found the problem: child.getId() returns null. Did I miss something? Should getIssue() return an empty issue without id?

Jira version 7.1.7


Solution

  • This should work:

    There's also this related question on Atlassian Answers that has some sample code.