groovyjiraatlassian-sourcetreejira-rest-apiscriptrunner-for-jira

Nullpointer exception when trying to execute issueLinkManager.createIssueLink


I am executing the following code in my scriptrunner console for Jira data center.

enter image description here

Here is the code: 

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.MutableIssue

def issueManager = ComponentAccessor.issueManager

def issueFactory = ComponentAccessor.issueFactory

def issueLinkManager = ComponentAccessor.issueLinkManager

def userManager = ComponentAccessor.userManager

def authenticationContext = ComponentAccessor.jiraAuthenticationContext

MutableIssue newIssue= ComponentAccessor.issueFactory.issue

log.warn(authenticationContext.getLoggedInUser())

issueLinkManager.createIssueLink(1521112 as long , 1782819 as long, 10070 as long, 1 as long, authenticationContext.getLoggedInUser())

I am getting a null pointer exception for the last line 

issueLinkManager.createIssueLink(1521112 as long , 1782819 as long, 10070 as long, 1 as long, authenticationContext.getLoggedInUser())

although none of the parameters is null. The error message is not telling me what the problem is. Anyone knows what to do in order to fix this problem? I am just trying to have a new feature issue linked to the superfeature main issue.  


Solution

  • The 2 first parameters needed to be inverted. I needed the child issue first and then the parent issue second.

      issueLinkManager.createIssueLink( 1782819 as long,1521112 as long, 10070 as long, 1 as long, authenticationContext.getLoggedInUser())