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

This widget could not be displayed.

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

This widget could not be displayed.

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

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

151 views 2 0
Join discussion

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