Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Report to show how many attachments are there on each issue/record

Domnic June 21, 2023

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         | 0
Issue 3         | 1

3 answers

2 votes
Evgenii
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2023

Hi, @Domnic 

Without additional plugins it's impossible. I made such functionality with ScriptRunner and groovy script.

Domnic June 21, 2023

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

Evgenii
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2023
/*
* Created 2023.
* @author Evgeniy Isaenkov
* @github https://github.com/Udjin79/SRUtils
*/

package ConsoleExamples

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query

AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser) as JqlQueryParser
SearchService searchService = ComponentAccessor.getComponent(SearchService)
UserManager userManager = ComponentAccessor.getUserManager()

//Username of user, that has rights to see issues
String username = "admin"
ApplicationUser techUser = userManager.getUserByName(username) as ApplicationUser

String jql = "project = TEST"
Query query = jqlQueryParser.parseQuery(jql)
SearchResults search = searchService.search(techUser, query, PagerFilter.getUnlimitedFilter())
List issues = search.results

String report = ""

issues.each { Issue issue ->
List<Attachment> attachments = attachmentManager.getAttachments(issue)
report += "Issue: ${issue.key}. Count: ${attachments ? attachments.size() : 0}\n"
}

log.warn(report)
Like Joseph Chung Yin likes this
Evgenii
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2023

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.

1 vote
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 21, 2023

@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.

0 votes
Hannes Obweger - JXL for Jira
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 26, 2023

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:

number-of-attachments.gif

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events