Help creating a subtask link to the parent issue

Gova Q September 15, 2020


     I would like your help in order to know why I am receiving the following error by using the Console on Jira Service Desk on Script Runner APP. 

I am creating a subtask and then link this one the to the parent but I have tried to test several solutions over the web and cannot get the root cause of the error I am getting:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.Issue

//Variables definition
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
Issue parentIssue = issueManager.getIssueObject('Jira-21')
def subTaskSummary = parentIssue.getSummary()
Map params = new HashMap()

MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "Low"
it.getName() == "Feedback"
// Add any other fields you want for the newly created sub task
log.debug("New issue ${newSubTask}")
params.put("issue", newSubTask)
//Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
Issue subtask = issueManager.createIssueObject(user, params)
ComponentAccessor.subTaskManager.createSubTaskIssueLink(parentIssue, subtask, user)
//subTaskManager.createSubTaskIssueLink(parentIssue, subtask, user) "Issue with summary ${newSubTask.summary} created"


The error I am getting is always:

2020-09-15 21:29:07,228 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-09-15 21:29:07,228 ERROR [common.UserScriptEndpoint]: Script console script failed: java.lang.NullPointerException at at at com.atlassian.jira.config.DefaultSubTaskManager.createSubTaskIssueLink( at com.atlassian.jira.config.SubTaskManager$ Source) at


The subtask is being created properly with all values I set but the link is the one that is not working.

I have invested several time looking for solutions but the ones I have tried over the internet are not working. 

Script Runner version: 6.9.1

Jira Server version: 8.8.1

Thank you in advance for your help about it because I am getting at the end of the wall :s

1 answer

0 votes
Cody Nelson March 10, 2021

Hi Gova, Having the same issue with Script Runner version 6.11.0 and Jira Server version 8.5.6, did you ever get a response or a resolution on this?

Gova Q March 29, 2022

Hi Cody!

   No one helped me on this. At the end I just create a custom script that allowed me to accomplish the task.

Let me know if you still have the issue, but I guess you already found a way.


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events