Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,406
Community Members
 
Community Events
168
Community Groups

Acces {{issue...}} smart value inside a list

Hi All,

I recently created a JIRA automation rule that send a email when een registration of software is done successful for a customer.
This is working fine for 99% the only problem is with the link to attachments.

i use the following way to add a list of attachments
{{#issue.attachment}}
<a href="{{content}}">Attachment: {{filename}}</a>
{{/issue.attachment}}

This is working fine for our employees that have a JIRA license. but the link generated from {{content}} is not accessible for our customer that have only a JIRA Customer account.

 the link that is generated is 

https://*JIRA URL*/secure/attachment/*AttachmentId*/*AttachmentFilename*

When i login the to the customer portal the url that the customer see from there is as followed

https://*JIRA URL*/servicedesk/customershim/secure/attachment/*AttachmentId*/*AttachmentId*_*AttachmentFilename*?fromIssue=*issueid*}}

So i thought i wood created the URL for the email my self.

{{#issue.attachment}}
<a href= "*JIRA ULR*/servicedesk/customershim/secure/attachment/{{id}}/{{id}}_{{filename}}?fromIssue={{issue.id}}">Attachment: {{filename}}</a>
{{/issue.attachment}}

But the problem is that the smart value ((isue.id}} is not giving the value back i think it is because it is inside the smart value list. when i use the {{issue.id}} outside the list it is working.

How do i use the {{issue.id}} in the smart value list

 

2 answers

1 accepted

2 votes
Answer accepted

Oke i fixed it by making a Scriptrunner field for it.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def baseurl = com.atlassian.jira.component.ComponentAccessor.getApplicationProperties().getString("jira.baseurl")

def issues = [issue] as List<Issue>
issues.addAll(issueLinkManager.getOutwardLinks(issue.id).collect {it.destinationObject})
issues.addAll(issueLinkManager.getInwardLinks(issue.id).collect {it.sourceObject})

issues.collect { issue ->
issue.getAttachments().collect { att ->
"<a href=\""+ baseurl+ "/servicedesk/customershim/secure/attachment/" + att.id + "/" + att.id + "_" + att.filename + "?fromIssue=" + issue.id + "\">" + att.filename + "</a>" + "<br/>"
}
}.flatten().join("")

 

That field i used to show me the links in the send email.
the only down side is that i show all attachments from the issue even when te customer does not have the proper rights for it.

0 votes

Hi @Cow Hills 

This is inside of the iterator processing for {{#issue.attachment}} so have you tried just {{id}} by itself?

Best regards,

Bill

Darryl Lee Community Leader Mar 10, 2021

My read on this was that {{id}} is returning the id of the Attachment, and they're hoping to refer back to the Issue id.

Would a (gulp) variable work?

{{origid}} = {{issue.id}}

And then try using {{origid}} in the list iteration?

Hi @Bill Sheboy , 

thanks for you answer {{id}} wil give back the attachment id but i need the id for the issue it self.

Hi @Darryl Lee ,

Thank you for the suggestion.
I have tried the following

{{origid}} = {{issue.id}}

{{#issue.attachment}}
<a href= "https://*JIRAURL*/servicedesk/customershim/secure/attachment/{{id}}/{{id}}_{{filename}}?fromIssue={{origid}}">Attachment: {{filename}}</a>
{{/issue.attachment}}

 

but still nothing.
i not even sure that the {{origid}} variable is working i am also unable to find anything about it in the documentation for JIRA Automation Server.

Darryl Lee Community Leader Mar 10, 2021

@Cow Hills does the link work without ?fromIssue=*issueid*?

Like in an incognito session, does this work:

https://*JIRA URL*/servicedesk/customershim/secure/attachment/*AttachmentId*/*AttachmentId*_*AttachmentFilename*

Because I wonder if the fromIssue part might be optional.

Darryl Lee Community Leader Mar 10, 2021

Sorry, when I wrote {{orgid}} = {{issue.id}} I was suggesting that you use the Create variable action to set the value. Example:

var2.png

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Create-variable-New-component/ba-p/1448118

@Darryl Lee 

No without the ?fromissue=*issueid* it is not working it will get a HTTP Status 400 – Bad Request

For the Create Variable function there is not support for the Server version and that is the one we use not the cloud version of JIRA.

Darryl Lee Community Leader Mar 10, 2021

Ahh, thanks for clarifying. I was just looking at my Cloud instance and did not see that attachment format at all. (You tagged this question as cloud, so that's why I was working from that assumption.)

I've unfortunately not had the opportunity to work with Automation on Server.

Reading this bug, I wonder if a possible workaround might be to add a comment with the attachment referenced thusly:

[^attachmentname.pdf]

Hi @Cow Hills 

Now that we know you are using Jira Server, I would like to suggest a pause and ask you to post an image of your entire automation rule.  That may provide more context for the community to offer ideas.

Thanks!

Hi @Bill Sheboy 

please see the following printscreen of the send email part of the automation rule.
image.png

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events