Pull in all comments for an issue

I have found sample code for pulling in comment timestamps as well as authors.

Does anyone have any sample code for pulling in all comments related to an issue so they can be displayed on the screen?

I am using the latest comment field which is added as a custom field to the overall Settings for Last Comment Date and Last Comment Text.

Thanks in advance,
Dennis

For anyone else looking to do this here is one option:

[jira.customfield_all_comments]
name = "All Comments"
data_type = "text"
javascript_code = '''
var commenta = new Array();
var allcomments = issue.fields.comment;
if (allcomments && allcomments.comments ) {
  var comments = issue.fields.comment.comments;
  for (var i = 0; i < comments.length; i++) {
    var comment = comments[i];
	  var commentdate = comment.created.toString().substr(0,19);
      commenta.push( commentdate + ', ' + comment.author.accountId + ', ' + comment.author.displayName + ', ' + comment.body );
      }
  issue.fields.customfield_all_comments = commenta.join("\n");
}
'''

This will provide the date / time stamp - author account id - author display name - comment body all on individual lines within the report.

The will show as oldest first and newest on the bottom.

1 Like

Hi @DennisT

It is great that you already found the answer to your own question and shared it with others.
Sharing is the real deal in communities!

Btw, that is the right way to import all comments in a property for each issue dimension member (by using a calculated field with Javascript in advanced settings)

Well done!
Martins / eazyBI support