Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner Listener Script error - Cannot get property 'issues' on null object

We use a Listener Script to sum the total Story Points up tp the Epic. Lately we have been seeing an error that we have not been able to debug. It does not happen for every issue. 

The error:

ERROR - Cannot get property 'issues' on null object on line 13

The code:

// Get the ID of the fields for Story Points and Epic Link
def storyPointsField = get("/rest/api/2/field").asObject(List).body.find {(it as Map).name == 'Story Points'}.id
def epicLinkField = get("/rest/api/2/field").asObject(List).body.find {(it as Map).name == 'Epic Link'}.id
def storyPointsTotalField = get("/rest/api/2/field").asObject(List).body.find {(it as Map).name == 'Story Points Total'}.id

// Retrieve all the issues in this issues' Epic
def epicKey = issue.fields."${epicLinkField}"
def storyPoints = issue.fields."${storyPointsField}""Epic Key is: " + epicKey)"Story Point is: " + storyPoints)

if (epicKey != null) { //This is to check if the event.issue's epic is null or not
def issuesInEpic = get("/rest/agile/1.0/epic/${epicKey}/issue")
.issues as List<Map>"Total issues in Epic for ${epicKey}: ${issuesInEpic.size()}")

// Sum the estimates
def estimate = issuesInEpic.collect { Map issueInEpic ->
issueInEpic.fields."${storyPointsField}" ?: 0
}.sum()"Summed estimate: ${estimate}")

// Now update the parent Epic
def result = put("/rest/api/2/issue/${epicKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
fields: [
"${storyPointsTotalField}": estimate,

// check that updating the parent issue worked
assert result.status >= 200 && result.status < 300

The error occurs at the bolded line in the code. I am looking for help on two items:

1. How do I debug the issue to see which issue/field is returning a null value

2. Can I limit the data being returned to just the Story Points field and would that help resolve the null "issues" error?

2 answers

Hi @JT , I would try to change

def issuesInEpic = get("/rest/agile/1.0/epic/${epicKey}/issue")
.issues as List<Map>


def issuesInEpic;
def issuesInEpicBody = get("/rest/agile/1.0/epic/${epicKey}/issue")
issuesInEpic = issuesInEpicBody?.issues

@Martin Bayer _MoroSystems_ s_r_o__ 

Thank you for the help. If I change my code as you suggested, I get e new error stating "the variable [body] is not undeclared"

Hi @JT , I tried to adjust my script... give it a try pls

Hi @Martin Bayer _MoroSystems_ s_r_o__ 

Still throwing an error:

2021-03-15 21:17:31.022 ERROR - No such property: body for class: Script1 on line 17
2021-03-15 21:17:31.040 ERROR - Class:, Config: null 

Hi @JT , I just tested following code and it works nice (tested with epic which contains issue and epic with no issues:

def issuesInEpic = get("/rest/agile/1.0/epic/CK-3/issue")
?.issues as List<Map>

But I can see, there is another body property/method used with put method. Can you try to remove empty spaces and put everything to one row?

// Now update the parent Epic
def result = put("/rest/api/2/issue/${epicKey}").queryString("overrideScreenSecurity", Boolean.TRUE).header('Content-Type', 'application/json').body([
fields: [
"${storyPointsTotalField}": estimate,

@Kristian Walker _Adaptavist_ 

Would you have a moment to review the script above? 

The script was working, with an occasional error, now the error is on most runs. I am unsure how to debug the get statement to find the "null" 

Hi @JT 

I would advise you to raise a ticket in our Support Portal together with the Correlation ID from hen the script if failing for us to check further on our end. 

Is the issue type is an Epic when the script runs as it would only run on Epic issues from the script. 

Also, Does the epicKey contain a value as if this Null. Then, your REST call would not return an issue. Can you include the REST call in an IF check to see if this value is Null so that the REST call is not made when this value is Null.

Id say maybe ask them to raise a ticket in our support portal with a correlation ID from when the script fails, also I would ask is the issue type an epic when the script runs as it would only run on epic issues from that script

Thank you. 

Kind Regards


Suggest an answer

Log in or Sign up to answer
Site Admin

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you