I use this method to add an attachment to an issue:
def attachmentManager = ComponentAccessor.getAttachmentManager()
def bean = new CreateAttachmentParamsBean.Builder(tempFile,
"keylead_"+reqCheckJSON["id"]+".pdf", //resultMap["set"][0]['note']+
'application/pdf',
currentUser,
issue).build();//copySourceFile=false
def changeItemBean= attachmentManager.createAttachment(bean)
But customers can't see the attachment.
I wondered maybe I should add the attachment as a comment.
I didn't find a way to make attachment visible to customers. Neither was I able to attach it as a comment.
What do you think is the right way and how?
Found the solution: After attaching the file to issue, a new comment should be added to it containing attached file name by [^ and ] tags like:
Attachment added [^filename.pdf].
This solution is only for ScriptRunner Server?
Any suggestions to use it on ScriptRunner Cloud ?
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try something like this,
def attachmentManager = ComponentAccessor.getAttachmentManager();
def issueManager = ComponentAccessor.getIssueManager();
CreateAttachmentParamsBean bean = new CreateAttachmentParamsBean.Builder(
tempFile, fileName, 'application/pdf', user, issue).build()
ChangeItemBean changeItemBean= attachmentManager.createAttachment(bean) issueManager.updateIssue(user,issue,new EventDispatchOption.Factory().get(EventType.ISSUE_UPDATED_ID),true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. Can you please give me a brief explanation on what it does? Or lead me to a book or other resource which explains the matter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no specific book, you can learn it from Jira's java api.
What it does is (line by line),
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can upvote or accept answer if it helped you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What this line exactly does?
I won't forget to upvote after I tested the solution. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What we have done before this like is update issue object in issue to have an attachment associated with it.
But to save these changes that we have to done to issue object has to be transferred to database. So we call,
issueManager.updateIssue(user,issue,new EventDispatchOption.Factory().get(EventType.ISSUE_UPDATED_ID),true)
This method update issue object to database and raise and event so other jira services can know that issue has been updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately nothing happened after I added that line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you need to confirm ScriptRunner team, this seems to be working fine on my instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.