How can I check if the author of a comment is a customer?

I need to identify if the first comment of an Issue was done by a customer. I’m able to get the first value author with JavaScript, but I don’t know how to identify if the author is a customer.

Any ideas?

Hi @Daniel_Luevano,

Jira Cloud returns “accountType” property for the comment author object.
You might create a JavaScript custom field that analyzes the author of the first comment and returns the relevant option.
That might work unless you have Atlassian users acting as customers.

For any alternative option please explain how you distinguish that the specific reporter is a customer. Is it some user-group?

Please share your JavaScript code for the first comment, as that might hint at a possible approach.

Regards,
Oskars / support@eazyBI.com

1 Like

Hi, team:

I’m also interested in this topic. Not to obtain the value of the first author, but to count all customer comments on an issue in order to derive a sort of ‘Customer Effort Score.’

In Eazy BI + Jira Software Server, I addressed this as follows:

[jira.customfield_external_comments]
name = "External Comments"
data_type = "integer"
measure = true
dimension = true
javascript_code = '''

if (issue.fields.comment && issue.fields.comment.comments) {
  var all_comments = issue.fields.comment.comments.length
  issue.fields.customfield_external_comments = all_comments
  
  for (i=issue.fields.comment.comments.length-1; i>=0; i--) {
    var commentItem = issue.fields.comment.comments[i];
    var result = getDocument("comment/" + commentItem.id + "/properties/sd.public.comment",{ignoreErrors: [404]});
    if (result && result.value) {
      if(result.value.internal) {
        issue.fields.customfield_external_comments--;
      }
    }
  }
}
'''

However, this approach no longer works in Jira Software Cloud, where we migrated a few weeks ago. Any ideas?

Thanks in advace!

Hi @pepe.munoz ,

The comment data in issue JSON on Jira cloud has a slightly different structure.
You might look for the comment author account type to identify the external comments.

The item to be checked might be

issue.fields.comment.comments[n].author.accountType

and the possible values are generally “atlassian” or “customer”

Regards,
Oskars / support@eazyBI.com

Thanks, @oskars.laganovskis:

I realized and I could solved with this javascript code:

var allcomments = issue.fields.comment;
var external_comments = 0;
if (allcomments && allcomments.comments ) {
  var comments = issue.fields.comment.comments;
  var customerComments = comments.filter(function(comment) {
    return comment.author && comment.author.accountType === "customer";
  });
  external_comments = customerComments.length;
  issue.fields.customfield_external_comments = external_comments;
}

Regards.

1 Like