However would like to know if a similar solution would work to get the comments made by a specific Assignee and / or Reporter.
I have Rows with a list of all existing projects, and would like to have a column with a user-defined, [Measure] > “Calculated member” that is able to show all the projects that “User X” has commented on.
To count comments by each author, you may modify JavaScript code. To do this, declare that each issue might have a set (array) of user names who have commented on it and comment count accordingly. To represent names of comment authors in eazyBI, you may use some existing dimension which contains user names, like, Assignee dimension.
Code for advanceds settings with JavaScript calcaulted custom field might look like this:
#Comments by user - Assignee
[jira.customfield_comments_byuser]
name = "Comments by user"
data_type = "integer"
measure = true
multiple_dimensions = ["Time","Assignee"]
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.created.toString().substr(0,10) + "," + comment.author.name + ",1");
}
issue.fields.customfield_comments_byuser = commenta.join("\n");
}
'''
In a report, use Assignee dimension to represent comment count by authors.
When trying this code with the “Test custom JavaScript code with the issue” option, I get the following error back: Execution of custom JavaScript code raised the following error:
unterminated string literal
In eazyBI are several places where you can paste in the JavaScript code.
When defining the new custom field, then you should paste the custom field definition with JavaScript code to get data for that custom field in eazyBI advanced settings (eazyBI >> Settings >> tab Advanced settings). This section is available to eazyBI administrators and Jira administrators. https://docs.eazybi.com/eazybijira/data-import/custom-fields/advanced-settings-for-custom-fields
The given code for “Comments” is a complete code for eazyBI advanced settings. If you want to test it beforehand, you might want to use only the JavaScript part between quotes ''' (see point 3).
For eazyBI customers who use eazyBI for Jira Cloud, a slightly different Javascript should be used to correctly map assignee names to “Assignee” dimension.
[jira.customfield_comments_byuser]
name = "Comments by user"
data_type = "integer"
measure = true
multiple_dimensions = ["Time","Assignee"]
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];
if(comment.author)
{
commenta.push(comment.created.toString().substr(0,10) + "," + comment.author.accountId + ",1");
}
else
commenta.push(comment.created.toString().substr(0,10) + "," + "(unassigned)" + ",1");
}
issue.fields.customfield_comments_byuser = commenta.join("\n");
}
'''
@Ramesh_Mashetty1
If you use the new calculated field (mapped to “Time” and “Assignee” dimension) imported as a measure with the “Assignee” dimension, you would see Assignee display names.
Or please share more details on where do you get the account ID exactly.
“Comments by user” is impored also as measure and mapped to “Assignee” and “Time” dimension.
If you won’t use accountID you won’t be able to analyze the count of comments by users.
Perhaps, you could drag “Assignee” dimension in rows and see comments split by assignees.
Or, you could create another calculated field “Comments by user name” from advanced settings and import it in the cube, where you could use the slightly different syntax in the Javascript where you use comment.author.displayName item from the JSON structure instead of accountID.
@martins.vanags I’ve tried the second option but no luck same output as for account ID
when trying first option it is throwing error as timeout error: 60 second please try making query simpler
It won’t be possible to map displayName to “Assignee” dimension, therefore, you could possibly import the new field only as property for “Issue” dimension members.
First, unimport the second field and import this field only:
[jira.customfield_comments_byusn]
name = "Comments by userName"
data_type = "string"
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];
if(comment.author)
{
commenta.push(comment.created.toString().substr(0,10) + "," + comment.author.displayName + ",1");
}
else
commenta.push(comment.created.toString().substr(0,10) + "," + "(unassigned)" + ",1");
}
issue.fields.customfield_comments_byusn = commenta.join("\n");
}
'''
Hello, can this code be adapted to show Internal comments and public comments for Jira service management? I tried adapting this because it shows accurate results, but while using
multiple_dimensions = [“Time”,“Assignee”]
In 2 custom calculated fields it gives me several errors while importing the data.
It should also be possible to import comments for JSM projects.
Please reach out to support@eazybi.com and share the errors and more details on what exactly you have tried to import.
@martins.vanags,
I am running into the same issue. The issue seems that the script only imports internal comments and counts them. I tried to adapt the script and I didn’t have any luck so far. If possible, could you post the solution here as well?