Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,887
Community Members
 
Community Events
184
Community Groups

ScriptRunner e-mail post function how to include 2 different file types as attachments

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?

2 answers

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 22, 2023 • edited

Hi @Kimi Nakashima

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:-

post_function-1.png

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:-

ksnip_20230522-174215.png

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:-

ksnip_20230522-174518.png

 

ksnip_20230522-174708.png

I hope this helps to answer your question. :-)

Thank you and Kind regards,

Ram

@Ram Kumar Aravindakshan _Adaptavist_ This totally worked! Thank you very much!

0 votes
Ken McClean
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 20, 2023

Can you provide the code you've come up with so far?  It's easier to help you troubleshoot

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
5.7.0
TAGS
AUG Leaders

Atlassian Community Events