Issue with Attachment Count custom field


I have an additional custom field I’m adding to reports to count the number of attachments on an issue in Jira.

When I use the Javascript to test within the import portion I get the correct count for the issue I am using for the test case.

When I add to the global settings and add to the project import I get no errors but, when I add to a report the display is blank, including the item i used to test.

Here is the overall code:

name = “Attachment Count”
data_type = “integer”
javascript_code = ‘’’
var numattachments = issue.fields.attachment.length;
issue.fields.customfield_attachment_count = numattachments;

The code in the measure looks correct as well after import:

[Issue].CurrentHierarchyMember.get(‘Attachment Count’)

Any thoughts on why this would be coming in blank on a report when the test shows a value of 1 for the same code?


Even using the code from another thread on this site:

name = “Attachments”
data_type = “integer”
measure = true
javascript_code = ‘’’
if(issue.fields.attachment && issue.fields.attachment.length >0) {
issue.fields.customfield_attachment = issue.fields.attachment.length;

Get the same output - shows a number when testing but when importing and adding to a report it shows as blank.


when using eazyBI for Jira Cloud try this code in advanced settings with shorter field ID and JSON fields additional row:

name = "Attachment Count"
data_type = "integer"
json_fields = ["attachment"]
javascript_code = '''
var numattachments = issue.fields.attachment.length;
issue.fields.customfield_attcnt = numattachments;

If you use eazyBI for Jira Data Center or Server, the same approach wont’work, then attachment field is not available in API results with JSON approach and you would need to import the attachment field directly from the Jira DB using SQL selects or Rest APIs (if available) and map it to issues cube.

Martins / eazyBI