Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Issue Manager getIssueObject oddity

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?

In the meantime, 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.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 =, user, PagerFilter.getUnlimitedFilter());
def issues = results.getIssues();
def issueObject = issues[0];
def issueObjectID = issueObject.getId();


But still would like to know why getIssueObject method is not working with string variable.

Thanks in advance for clarifying this oddity for me!

3 answers

1 accepted

0 votes
Answer accepted
Daniel Yelamos [Adaptavist]
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.
Apr 05, 2017


I have set up a test environment and it seems to work. I have attached this customlistener to every issue event. As you can see here:



Could you tell us which event you are attaching the listener to so that we are able to give it a try?



Thank you for testing!

The Custom Listener I have defined triggers on "Issue Resolved" event.

Jira that I am testing this on is v7.3.0.

Maybe there is a problem with that specific version of Jira - what version are you using?

Daniel Yelamos [Adaptavist]
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.
Apr 05, 2017

Hi Ron.

Glad to run some testing for you. We checked out different jira versions, 7.3.0, and 7.3.3 and in both cases it worked. We realized that in your issue, we see that in the original question, you have:


def issueKey = "JIRA-1234";


however, you say it does not work when:


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

We've noticed that the two keys are different. Could this be the cause of your issue? 



Thanks for some more testing!

I am glad this works in general and causing problem only for me.

I use actual project key from our Jira instance - the "JIRA-1234" and "KEY-1234" are just examples.

Problem still persists for me but I have a workaround (I shared it in the initial post - so I'm good).

Also this hopefully won't be a problem soon as we migrate to different Jira instance (and I hope this problem will disappear).

It works!

def issueKey = "JIRA-1234";
def issueManager = ComponentAccessor.getIssueManager()
def issueObject = issueManager.getIssueObject("${issueKey}")

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 04, 2017

It looks like it doesn't think it's a string.

Official Jira docs says it needs to be a String:

But even after explicitly specifying type of the variable or converting it to string the error persist.

Go figure...

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events