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.Issue
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption
search = { 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()
}
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.