issue.get("comment") don't work as expected

Hi,

I'm using JIRA Misc Custom Fields 1.7.0 with JIRA v7.0.0#70107. Always get NullPointerException when I'm trying to issue.get("comment") for a List<> of comments. Full formula is:

<!-- @@Formula:
int numComments = issue.get("comment").size();
if(numComments > 0)
{
return (issue.get("comment")).get(size-1).getUpdated();
}
else
{
return new Date(issue.get("updated"));
}
-->

and eval of first string throws an exception. Issue have several comments. Tried in different ways, results in nothing, so your's advice wanted. Thanks!

7 answers

This is in fact a bug in JIRA Misc Custom Field 1.7.0 (and 1.6.3). It is tracked at: https://innovalog.atlassian.net/browse/JMCF-196

The bug is already fixed and a new release is on the way.

Sorry for the inconvenience,

David

Version 1.7.1 is released.

Thanks a lot!

Can you post the full error (with stack trace) you found in your log file?

I don't get a stack trace but the following messages 2015-11-18 11:42:50,667 http-nio-8080-exec-4 ERROR dmitry.shaidaev 702x2823x2 16k788g 185.36.63.236,185.36.63.206,0:0:0:0:0:0:0:1 /rest/issueNav/1/issueTable [c.i.jmcf.fields.CalculatedDateField] CalculatedDateField: error evaluating formula of field "Last Commented" of issue CUTMAN-5: Sourced file: inline evaluation of: `` int numComments = issue.get("comment").size(); if(numComments > 0) { retur . . . '' : Typed variable declaration : at Line: 2 : in file: inline evaluation of: `` int numComments = issue.get("comment").size(); if(numComments > 0) { retur . . . '' : .size ( ) Target exception: java.lang.NullPointerException: Attempt to invoke method size on null value Navigate to the following URL to edit the formula: https://octonus-teams.com/cutjira/secure/admin/EditCustomField!default.jspa?id=12821 In c:\Atlassian\Data\JIRA\log\atlassian-jira.log

And you confirm that issue CUTMAN-5 has at least one comment, right?

Yes. But some of the issues from table-view filter (which includes this custom field) may not have comments.

P.S.: Initial formula have an error, "get(size-1)", I've fixed to "get(numComments-1)", but it don't help.

I'm looking into it.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

313 views 0 6
Read article

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