In our workflow we have a transition called "Ship product". During this transition an email is sent to our shipping location that has instructions on how to ship a requested product. Included in that email is a shipping label and occasionally if our customer requires it, a cover letter. I wish I could use the include all attachments option but sometimes the issue has attachments other than the shipping label and cover letter like their company logo from their email replies. I don't want those to be emailed to the shipping dept because anything attached to the email will end up printed and included in the package. So since the shipping labels are always pdf files and the cover letters are always Word files, I tried to use the custom option.
Using the snippet example I was able to get either the pdf to send or the doc file but I couldn't get them both to send and I couldn't figure out how to manipulate it to send them both. Is it not possible?
I assume you are using ScriptRunner's Send Custom Email Post-Function for your requirement.
If yes, you can follow the steps below:-
1. First, ensure that you have selected the Custom option in the Include Attachments section.
2. Add the code below into the Custom Attachments Callback field:-
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.MailAttachment
{
MailAttachment a ->
def filename = a.filename.toLowerCase()
filename.endsWith('.pdf') || filename.endsWith('.docx') || filename.endsWitch('.doc')
}
Please note that the working custom code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot for your reference:-
Below are a couple of test screenshots:-
1. In the sample issue, there are a couple of attachments included, i.e. png, pdf and doc file types as shown in the screenshot below:-
2. Once the issue transitions to In Progress, the mail is triggered. However in the mail as expected, only the pdf and docx file types are included as shown in the screenshots below:-
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide the code you've come up with so far? It's easier to help you troubleshoot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.