Nullpointer exception when trying to execute issueLinkManager.createIssueLink

Mouna Hammoudi September 21, 2023

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

 

Capture.PNG

 

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.  

1 answer

0 votes
Hauke Bruno Wollentin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2023

I'd guess that one of the given objects (either one of the issues or the link itself) doesn't exist.

You can try to cross-check this while loading the corresponding objects with your given IDs, for example

issueManager.getIssueObject(1521112)
issueManager.getIssueObject(1782819)

Suggest an answer

Log in or Sign up to answer