I want a user selecting an existing issue attachment during a transition in order to do something with the selected attachment in the post function.
How to get an attachment picker?
I think I got it myself. I am using the custom picker of Scriptrunner.
import com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.attachment.Attachmentimport com.atlassian.jira.component.ComponentAccessorimport com.onresolve.scriptrunner.canned.jira.fields.model.PickerOptionsearch = { String inputValue, Issue issue -> issue.getAttachments().findAll { it.getFilename().contains (inputValue ?: '') }}toOption = { Attachment attachment, Closure<String> highlight -> new PickerOption( value: attachment.getId(), label: attachment.getFilename(), html: highlight(attachment.getFilename(), false), )}getItemFromId = { String id -> ComponentAccessor.getAttachmentManager().getAttachment(id as Long)}renderItemViewHtml = { Attachment attachment -> attachment.getFilename()}renderItemTextOnlyValue = { Attachment attachment -> attachment.getFilename()}
It looks like you're new here. Sign in or register to get started.