Hello,
I wanted to check if there is a way I can create a report where it shows each issue and give the count of attachments/invoices
Example
Issue name | Number of Attachments
Issue 1 | 2
Issue 2 | 0Issue 3 | 1
Hi, @Domnic
Without additional plugins it's impossible. I made such functionality with ScriptRunner and groovy script.
HI @Evgenii
Thanks for responding back. How can I use ScriptRunner or Groovy to create this report. Any guidance will be much appreciated.
Thanks,Domnic
/* * Created 2023. * @author Evgeniy Isaenkov * @github https://github.com/Udjin79/SRUtils */package ConsoleExamplesimport com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.AttachmentManagerimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.attachment.Attachmentimport com.atlassian.jira.issue.search.SearchResultsimport com.atlassian.jira.jql.parser.JqlQueryParserimport com.atlassian.jira.user.ApplicationUserimport com.atlassian.jira.user.util.UserManagerimport com.atlassian.jira.web.bean.PagerFilterimport com.atlassian.query.QueryAttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser) as JqlQueryParserSearchService searchService = ComponentAccessor.getComponent(SearchService)UserManager userManager = ComponentAccessor.getUserManager()//Username of user, that has rights to see issuesString username = "admin"ApplicationUser techUser = userManager.getUserByName(username) as ApplicationUserString jql = "project = TEST"Query query = jqlQueryParser.parseQuery(jql)SearchResults search = searchService.search(techUser, query, PagerFilter.getUnlimitedFilter())List issues = search.resultsString report = ""issues.each { Issue issue -> List<Attachment> attachments = attachmentManager.getAttachments(issue) report += "Issue: ${issue.key}. Count: ${attachments ? attachments.size() : 0}\n"}log.warn(report)
@Domnic -
I agreed with Evgeniy's response. However if you have Scriptrunner for Jira add-on, then you can take a look at the following reference page for this add-on (Data Center/Server) using the build-in JQL function
https://docs.adaptavist.com/sr4js/latest/features/jql-functions/included-jql-functions/attachments
This will be a great starting point and you can create your own JQL functions -
https://docs.adaptavist.com/sr4js/latest/features/jql-functions/custom-jql-functions
Hopefully, this will get you going. Please note that the above recommendation allows you to gather the data first, then you will need to go further to develop your reporting needs.
Hope this helps.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Technology Applications Team
Viasat Inc.
Thanks, @Joseph Chung Yin I forgot to tell, that with scriptrunner can be made scripted field, which can count attachments. Your comment reminded me about this opportunity.
Hi @Domnic
if you are option to solutions from the Atlassian Marketplace, this would be trivial to do using the app that my team and I are working on, JXL for Jira.
JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you’d do in e.g. Excel or Google Sheets. It also comes with a number of so-called "smart columns" that aren’t natively available, including the number of attachments (along with several other attachment-related smart columns).
This is how it looks in action:
As you can see above, you can easily sort and filter by the number of attachments, and also use it across JXL's many advanced features, such as support for (configurable) issue hierarchies, issue grouping by any issue field(s), sum-ups, or conditional formatting. This all "just works"; there's no scripting whatsoever required.
Since you've tagged your question for Jira Server: As you may have heard, app sales have ended for Jira Server. Are you planning to migrate to Data Center or Cloud? I'd strongly recommend that. If you need some more time, JXL is perfectly compatible with Jira Server; it's just that we need to generate a license for you. If the above looks interesting, just let me know, and I'll happily start a free trial for you.
Any questions just let me know,
Best,
Hannes
It looks like you're new here. Sign in or register to get started.