I am using email this issue script runner post function. I need to find last/latest attachment in an issue and email that as part of closure notification. I found below script and its working for pdf format, but i tried deriving for all format but it couldn't.
Can any one help ?
----------------
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.MailAttachment
{
MailAttachment a ->
def issue = a.issue
def allAttachments = issue.attachments
def latest = allAttachments.findAll {
it.filename.endsWith(".docx")
it.filename.endsWith(".jpg")
it.filename.endsWith(".png")
it.filename.endsWith(".xlsx")
it.filename.endsWith(".pdf")
}.sort { it.created }.last()
return latest.id == a.id