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
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.
Hi @Cow Hills
This is inside of the iterator processing for {{#issue.attachment}} so have you tried just {{id}} by itself?
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy ,
thanks for you answer {{id}} wil give back the attachment id but i need the id for the issue it self.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, when I wrote {{orgid}} = {{issue.id}} I was suggesting that you use the Create variable action to set the value. Example:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.