extract comment information from jira to eazybi report

Martin Lituanas July 24, 2014

Hi,

A report is requested in eazybi to include issue comments from JIRA this includes comments created under subtask.

What property and dimension can we use to capture issue comments from JIRA?

We would appreciate help in here.

Thanks.

1 answer

0 votes
Lauma Cīrule
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.
July 27, 2014

Hi!

As issue comments as well as description usually is not used for reporting they are not imported by default.

Do you wish to import all comments text or just the count of comments per sub-task issue?

For now I can suggest to add JIRA Misc Custom field that would retrun Issue comments and then this custom field could be imported to eazyBI.

Please let me know if you need additional help with JIRA Misc custom field. You can contact me directly at support@eazybi.com.

Kind regards,
Lauma

eric anier
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.
July 29, 2014

Hi Lauma,

We intend to import all comments including comments of sub-tasks, would JIRA Misc Custom field be able to handle this requirement?

Thanks,

Lauma Cīrule
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.
July 30, 2014

Hi Eric!

Yes, the following formula in JIRA MISC custom text field description would return Issue comments as well as Issue sub-task comments, if sub-tasks exist

<!-- @@Formula:
import org.apache.commons.lang.StringUtils;
import com.atlassian.jira.component.ComponentAccessor;

commentManager = ComponentAccessor.getCommentManager();

allComments = new ArrayList();

issueComments = commentManager.getComments(issue.getIssueObject());
if (issueComments != null) {
  for (comment : issueComments) {
    allComments.add(comment.getBody());
  }
}

subTasks = issue.getIssueObject().getSubTaskObjects();

if (subTasks != null) {
  for (subTask : subTasks) {
    subTaskComments = commentManager.getComments(subTask);
    if (subTaskComments != null) {
      for (subTaskComment : subTaskComments) {
        allComments.add(subTaskComment.getBody());
      }
    }
  }
}

if (allComments.isEmpty()) return null;
StringUtils.join(allComments, "\n");
-->

If you do not wish to see this custom field in JIRA Issue screen, then please configure to not show it in any of screens. It will still be possible to import comments as Issue proeperty in eazyBI.

To see this new calculated field in eazyBI custom field selection you would need to add following lines in eazyBI Advanced settings

[jira.customfield_NNNNN] 
data_type = "text"

where NNNNN is custom field number.

When advanced settings are saved go to Source Data tab and select to import the new custom field. After import you will be able to see comments when new measure is selected on columns and Issue dimension / Issue level on rows.

Please note that if you use Oracle database then maximum lenght of the custom text field can be 4000 symbols. If you have very long comments they might be cut to this lenght.

Let me know if you have additional questions!

G_ Richard Bellamy December 28, 2015

Sorry to necro-bump this thread, but unfortunately, the JIRA Misc Custom field plugin isn't available for Cloud customers. Are there any plans for Cloud availability?

Lauma Cīrule
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.
December 29, 2015

Hi Richard, I did answer to your e-mail as well. Shortly here as well - yes, for JIRA Cloud similar calculation can be done using JavaScript calculated custom fields. See more details here https://docs.eazybi.com/display/EAZYBIJIRA/JavaScript+calculated+custom+fields. Kind regards, Lauma / support@eazybi.com

Nguyễn Hoàng December 19, 2018

Hi Lauma,

I tried to find how to import the issue's comment through JavaScript like you said above, but I have no idea what to do, what is the script for Advance settings in eazyBI. Can you help us?

Sir Mārtiņš Vanags
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.
December 19, 2018

Hi,

in eazyBI for Jira Cloud one of the ways would be creating a new calculated Javascript field (via advanced settings) to count the total number of Issue comments and import as measures in eazyBI. It would count the total number of comments for each Issue (see attachment below)

 

[jira.customfield_comments]
name = "Comments"
data_type = "integer"
measure = true
javascript_code = '''
if (issue.fields.comment && issue.fields.comment.comments ) {
issue.fields.customfield_comments = issue.fields.comment.comments.length;
}
'''

 

Another way would be displaying all comments as a property for an issue (see attachment below)

 

[jira.customfield_comments_for_issues]
name = "Comments details"
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];
commenta.push(comment.body + " (" + comment.author.displayName + ", " + comment.created.toString().substr(0,10) + ")");
}
issue.fields.customfield_comments_for_issues = commenta.join("\n");
}
'''

 

Martins / eazyBI support,

 

Issue comments.png

Like Jonathan Paul Merino likes this
Deleted user July 8, 2019

How can we differentiate comments that are internal and external?

Ilze Leite-Apine
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.
July 25, 2019

Hi, 

As far as I know, there is no information in Jira whether it is an internal or external comment. If you can retrieve that from comment user name or email, you can add those conditions directly in the JavaScript code or in Jira Misc code and retrieve separately (in two custom fields) internal and external comments. Otherwise, those comments could not be distinguished in eazyBI.

Ilze, support@eazybi.com

Nawed Farooque August 1, 2019

I've added the following code into the advanced settings:

[jira.customfield_comments]
name = "Comments"
data_type = "integer"
measure = true
javascript_code = '''
if (issue.fields.comment && issue.fields.comment.comments ) {
issue.fields.customfield_comments = issue.fields.comment.comments.length;
}
'''

but I can't see a new field for measuring, how can I use the field now?

Nawed Farooque August 1, 2019

Okay I got it :D I forgot to implement the new field via the source

Suggest an answer

Log in or Sign up to answer