Issue Manager getIssueObject oddness Edited

I was working on script for a Custom Listener (using Jira 7.3 and ScriptRunner 4.3) and noticed that following piece of code works:

import com.atlassian.jira.component.ComponentAccessor

def issueKey = "JIRA-1234"; def issueManager = ComponentAccessor.getIssueManager() def issueObject = issueManager.getIssueObject("JIRA-1234") def issueObjectID = issueObject.getId()

But when:

def issueObject = issueManager.getIssueObject("KEY-1234")

is being replaced by:

def issueObject = issueManager.getIssueObject(issueKey)

The code just assigns null to the issueObject variable and code returns following error:

java.lang.NullPointerException: Cannot invoke method getId() on null object

So in other words when the issue key is used directly as parameter for getIssueObject method - the code works. But when variable is used as a parameter - the code doesn't work.

Any idea why this is happening?

BTW, I have circumvented this problem using Search Provider (I share workaround in case somebody has similar problem and needs working solution):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.web.bean.PagerFilter

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser);
def searchProvider = ComponentAccessor.getComponent(SearchProvider);
def authContext = ComponentAccessor.getJiraAuthenticationContext();
def issueKey = "JIRA-1234";
def jqlQuery = jqlQueryParser.parseQuery(issueKey);
def user = authContext.getLoggedInUser();
def results = searchProvider.search(jqlQuery, user, PagerFilter.getUnlimitedFilter());
def issues = results.getIssues();
def issueObject = issues[0];
def issueObjectID = issueObject.getId();

Thanks in advance for clarifying this oddness for me!

1 answer

This widget could not be displayed.
Sam Hall Community Champion Apr 05, 2017

Hi Ron - Is this is duplicate of Issue Manager getIssueObject oddity?

If so, and you are happy your issue got solved, we could close this thread.

Let me know.

It seems to be the exact same question Sam.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

79 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you