All eazyBI for Jira eazyBI for Confluence Private eazyBI

First comment when issue flagged
eazyBI for Jira

Import the body of the first comment when the issue was flagged in Jira. Replace NNNNN  with the ID of the field "Flagged".

Account-specific calculated field

Account specific calculated fields are defined in Source Data → Import options.

Settings for the new field

Internal name

fflcomment

Display nameFirst comment when flagged
Data type

text 

Additional advanced settings
json_fields = ["comment"] #this line is mandatory

Custom JavaScript code:

if (issue.fields.customfield_NNNNN && issue.fields.comment && issue.fields.comment.comments
    && issue.fields.comment.comments.length > 0) {
  var commentsarray = issue.fields.comment.comments;
  for (var i = 0; i < commentsarray.length; i++) {
    var commenthist = commentsarray[i];
    if (commenthist.body && commenthist.body.indexOf("(flag) Flag added")>=0
       ) {   
         var flcomment = commenthist.body.split('Flag added\n\n')[1];
          break;
        }
  }
  if(issue.fields.customfield_NNNNN){
    return flcomment;}
}

Global calculated field

Global calculated fields are defined in eazyBI advanced settings.

Here are the settings for the new field definitions. You should insert the JavaScript (the code given above) below the line // Insert here the Custom JavaScript codeKeep the opening and closing quotation marks. ''', do not delete them.

#First comment added with Flag
[jira.customfield_fflcomment]
name = "Comment when flagged"
data_type = "text"
json_fields = ["comment"]
javascript_code = '''
// Insert here the Custom JavaScript code
'''