'Time to first response’ / exclude attachments/reporter comments being counted as first comments

Hi eazyBI Support/Community

My first writing here, please bare with me :wink:

I have created ‘Time to first comment’ custom field according to this post in the community: Creating a Time to First Comment date.

So far so good…

The issue I’m now experiencing is that whenever a new ticket is opened and the reporter adds an attachment, the attachment is apparently added by the system after the ticket has been opened and JIRA is counting that as the first comment.

Since we’re monitoring this ‘Time to first comment’ custom field for SLA measurement the metrics obviously gets quite skewed.

Would you know a way to either exclude attachments from counting as a comment, or how to exclude the reporters comments from being counted as first comments?

Appreciate any thoughts and/or tips,

Best regards,

Caj

Hi @dodge365
Welcome to the eazyBI community.

You could try a slightly different version of Javascript to find the first comment added by user who is not also a reporter of the issue.

[jira.customfield_firstcommentdate]
name = "First comment date"
data_type = "date"
javascript_code = '''
if (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.author && 
        commenthist.author.key != issue.fields.reporter.key) {     
          var admincomment = commenthist.created.substr(0, 10);
          break;
        }
  }
  issue.fields.customfield_firstcommentdate = admincomment;
}
'''

Note that changing the Javascript for an already imported custom field would require double imports (one import without field selected, second with field selected again) to reset the code

Martins / eazyBI

Thanks for the solution @martins.vanags

Best regards,
Caj