Scriptrunner - Send Custom Email postfunction, copying specific attachments

Josiah_Sansone April 15, 2020

I'm trying to set up a Scriptrunner postfunction in my workflow in JIRA to send a custom email, and one of the things I want to do is attach one of the file attachments on the issue to the email.  If I select to send "all" attachments, it works fine.  But if I select custom and try to do a callback to limit which attachment is sent, it doesn't work.  The suggested script for this (example of sending only PDF attachments) is this:

import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.MailAttachment

{MailAttachment a -> a.filename.toLowerCase().endsWith('.pdf')

 

This doesn't seem to work, nor does my attempted modification:

import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.MailAttachment

{MailAttachment a -> a.filename.toLowerCase().contains('GTC')

Also tried 

import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.MailAttachment

{MailAttachment a -> a.filename.toLowerCase().startsWith('GTC')

None of these options result in any attachments being sent.  What am I doing wrong?

 

I have another question about how to access linked issues values (like a sub-task issue key/link) in the email content, if anyone knows how to do that as well.  I've been able to access custom fields in the email content but haven't been able to figure out how to get a linked issue key.

 

Thanks!

Josiah

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events