Is there any way to show in a column in Issue Navigator the names of the attachments for an issue?
Thanks in advance,
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
This is better, it gives you clickable file names (to download them) and also lists multiple attached file names:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.config.properties.APKeysdef 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.
Hello,
I see null, Is that because of the file path?
C:\Users\home\Atlassian\Application Data\Jira\data\attachments
this my path for attachments. script seems to be good but see null when I preview.
Thanks in advance.
Hi,
I want to display sum of two number fields to third number field.
ex: 1 Support Count CRM(2.0) = 510
2 Support Count CRM(Old) = 10
3 Support Count CRM(New) = 4
Calculate the sum of 2 custom fields (2+3) to the third custom field (1)
Hello Andrews,
Create a scripted field and insert this script below, and add the scripted field to the view screen.
import com.atlassian.jira.component.ComponentAccessor;import com.atlassian.jira.issue.MutableIssue;import com.atlassian.jira.issue.CustomFieldManager;import com.atlassian.jira.issue.fields.CustomField;import com.atlassian.jira.issue.Issue;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();def issueManager = ComponentAccessor.getIssueManager();
//your first fieldCustomField custNum = customFieldManager.getCustomFieldObjectByName("numfield1");def custNumValue = issue.getCustomFieldValue(custNum);
//your second fieldCustomField anotherCustNum = customFieldManager.getCustomFieldObjectByName("numfield2");def anotherCustNumValue = issue.getCustomFieldValue(anotherCustNum);
//your third fieldCustomField anotherCustNum2 = customFieldManager.getCustomFieldObjectByName("numfield3");def anotherCustNumValue2 = issue.getCustomFieldValue(anotherCustNum2);
if(custNumValue !=null && anotherCustNumValue != null && anotherCustNumValue2 != null) {def finalValue = custNumValue+anotherCustNumValue+anotherCustNumValue2;return finalValue;}
Thanks!!
It looks like you're new here. Sign in or register to get started.