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()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.