How to show attachments in Issue Navigator

Is there any way to show in a column in Issue Navigator the names of the attachments for an issue?

Thanks in advance,

2 answers

1 accepted

9 votes
Accepted answer

Currently not possible - https://jira.atlassian.com/browse/JRA-4737

However you might be able to implement that using custom scripted field (Script Runner) which will display attachment names for an issue and you'll be able to add it as a column in the issue navigator.

Here's a sample groovy code for the field:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys

def attachments = ComponentAccessor.getAttachmentManager().getAttachments(issue)
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)

attachments.collect {
    '<a href="' + baseUrl + '/secure/attachment/'+ it.id +'/'+
        URLEncoder.encode(it.filename, "UTF-8") +'">' + it.filename + '</a>'
}.join("<br>")

(Modified by @Jamie Echlin [Adaptavist] to support attachment filenames containing spaces Nov 2016).

Use script field config: Template: HTML.

 

Thanks for sharing the script.

Thank you, @Jamie Echlin [Adaptavist]!!

You're welcome, and thanks to @Boris Georgiev [Botron] too wink

Thank you, that's just what we need!

This is better, it gives you clickable file names (to download them) and also lists multiple attached file names:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys

def attachments = ComponentAccessor.getAttachmentManager().getAttachments(issue)
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)

attachments.collect {
'<a href="' + baseUrl + '/secure/attachment/'+ it.id +'/'+
URLEncoder.encode(it.filename, "UTF-8") + '"' + '>' + it.filename + '</a>' + '<br>'
}.join('<br>')

Hi, @Johan Geens

I've got this error while trying this script:

2018-04-24 08:33:30,515 ERROR [customfield.GroovyCustomField]: *************************************************************************************
2018-04-24 08:33:30,515 ERROR [customfield.GroovyCustomField]: Script field failed on issue: WBL-45930, field: Attachments(Script)
groovy.lang.MissingMethodException: No signature of method: com.onresolve.scriptrunner.customfield.GroovyCustomField$_getValueFromIssue_closure1.doCall() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [Attachments, []]
Possible solutions: doCall(java.lang.Object), findAll(), findAll()
 at Script1435.run(Script1435.groovy:43)

Can you help me to figure it out?
Thanks

 

Use this groovy code in Script Field it works!! But it need to create new custom field.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

153 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you