Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Iterating to get the summary

Gowri_Sankar
Contributor
November 18, 2019

Hi,

 

I have a custom field which is of multi select and it stores only the key. In order to fetch the value I'm writing a listener event during creation and updating event where the key will be converted from string to list and then iterating the list to get the summary.

The summary is being iterated for the first element in the list.

However, the iteration is not successful and  throws the below error:

 

Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script>
java.lang.NullPointerException: Cannot invoke method getSummary() on null object
	at com.atlassian.jira.issue.Issue$getSummary$9.call(Unknown Source)

 

wordlist = new ArrayList(Arrays.asList(str))
wordlist.each{
def value = it.toString()
if(it){
def issueTex = issueManager.getIssueObject("${value}")
def summary = issueTex.getSummary()
}
}

1 answer

0 votes
Andrej Freeze _ greenique
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.
November 18, 2019

Hello @Gowri_Sankar I'm not sure of what you are trying to achieve, but basically you are getting a nullpointer exception.

def issueTex = issueManager.getIssueObject("${value}")

This line does not seem to return a value and issueText is left empty. In the next line, issueText is traing to call the method "getSummary", but due to it being empty, you receive a NullPointer Exception.

I hope this was of any help.

Gowri_Sankar
Contributor
November 19, 2019

Hi @Andrej Freeze _ greenique 

 

Thanks. Yes correct, but considering a list has 3 values. On the first iteration the getSummary is executed. But on further iterations, this returns null. To make sure the value is present I have added an if loop inside for loop. On second, iteration it is iterated for IF but when trying to access issueManager.getIssueObject the variable returns null.

Suggest an answer

Log in or Sign up to answer