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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to add email addresses in SendCustomEmail

Hello everyone!
I'm using script runner and "Send a custom email" listener.I want to add (automatically) emails in "" field.
I think, the solution is to use custom groovy script which can call this listener and add emails in that field.
I have some questions:
How can I call this listener? and How can I add emails in that field?

Sorry for my bad language.
Any help would be greatly appreciated!

2 answers

1 accepted

1 vote
Answer accepted

If you want to dynamically change the recipients, you should send it to the value of a user or multiuser custom field, and you set the value of that to a user or list of users.

So "To Addresses" is for email addresses, "To Fields" is for using fields to govern the recipients.

Hi Jamie, thanks for the answer. Can you provide some guidance how to do it better? I tried to get watchers: watcherManager.getCurrentWatcherUsernames(issue); and then get email addresses via watcherUser.getEmailAddress(); It works, but it only a half of work:) How can I add these email addresses? Explain me please. I also tried to create some custom groovy for sending email: Email email = new Email(emailTo); email.setSubject(subject); email.setBody(content); mailServer.send(email); But I don't know how to add files like your "Send a custom email" listener.

I understood all. thank you. Solved.

I have below under condition and configuration for send a custom email which is working okay. Now If I include Geo channel the script will be lengthy and will cause performance issue. How can I use geo channel along with product and keep the script short and simple to make sure there is no performance issue. Kindly suggest!

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager

def plugin = ComponentAccessor.getPluginAccessor().getPlugin("com.valiantys.jira.plugins.SQLFeed")
def serviceClass = plugin.getClassLoader().loadClass("com.valiantys.nfeed.api.IFieldDisplayService")
def fieldDisplayService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def key = issue.getKey()
//get H24 product(Product name)
def product_string = fieldDisplayService.getDisplayResult(issue.getKey(), "customfield_20812")
def String product_stringValue = (product_string != null ? product_string.getDisplay() : '')
//SF Account

//Account name?
def account_String = fieldDisplayService.getDisplayResult(issue.getKey(), "customfield_28808")
def String account_StringValue = (account_String != null ? account_String.getDisplay() : '')
//case number?
def caseNumber = customFieldManager.getCustomFieldObjectByName("Case Number")
def caseNumberFieldValue = issue.getCustomFieldValue(caseNumber)
//customer contact name?
def contactName_String = fieldDisplayService.getDisplayResult(issue.getKey(), "customfield_20908")
def String contactNameValue = (contactName_String != null ? contactName_String.getDisplay() : '')
//Date (issue created)?
def issueCreate = issue.getCreated()
//case subject(summary)?
def summary = issue.getSummary()
//customer impact?
def customrImpact = customFieldManager.getCustomFieldObjectByName("Customer Impact")
def customrImpactFieldVaue = issue.getCustomFieldValue(customrImpact)
//customer impact notes?
def customrImpactNotes = customFieldManager.getCustomFieldObjectByName("Customer Impact Notes")
def customrImpactNotesFieldVaue = issue.getCustomFieldValue(customrImpactNotes)
//case description?
def description = issue.getDescription()
//Last comment
def comment = ComponentAccessor.getCommentManager().getLastComment(issue).getBody()

//Geo channel
def geoChannel = fieldDisplayService.getDisplayResult(issue.getKey(), "customfield_27009")
def String geoChannelValue = (geoChannel != null ? geoChannel.getDisplay() : '')
//Email Subject
def emailSubject = "UPDATE: $product_stringValue Priority 1 for $account_StringValue"
//Email Template(Body)
def String emailBody = "***For internal use only and not for further dissemination.***\n \nThis email is to inform you of a $product_stringValue Priority 1 Case for $account_StringValue Case $caseNumberFieldValue. \n$contactNameValue contacted HELP24 on $issueCreate to report a priority 1 situation occurring on $product_stringValue. \n\nCase Subject: \n$summary \n\nCustomer Impact: $customrImpactFieldVaue \n\n$customrImpactNotesFieldVaue \n\nCase Description: \n$description \n\nUpdates: \n$comment \n\nThe HELP24 team is currently investigating this issue and will provide regular updates directly to the customer. Updates on this P1 case will follow until the case is resolved. \n\n\nRegards, \nThe Global HELP24 Team\n$caseNumberFieldValue \n$key"


if (product_stringValue == "BASE24") {
} else if (product_stringValue == "BASE24-eps") {
} else if (product_stringValue == "Commerce Gateway") {
} else if (product_stringValue == "COMMS") {
} else if (product_stringValue == "Enterprise Banker") {
} else if (product_stringValue == "Global Trade Manager") {
} else if (product_stringValue == "GoldenGate") {
} else if (product_stringValue == "ISD") {
} else if (product_stringValue == "Mobile Channel Manager") {
} else if (product_stringValue == "MTS") {
} else if (product_stringValue == "NETWORK SYSTEMS") {
} else if (product_stringValue == "OCM24") {
} else if (product_stringValue == "iExchange") {
} else if (product_stringValue == "Online Banking") {
} else if (product_stringValue == "Payments Management") {
} else if (product_stringValue == "Postilion") {
} else if (product_stringValue == "PRISM") {
} else if (product_stringValue == "PRM") {
} else if (product_stringValue == "RCS") {
} else if (product_stringValue == "Token Management") {
} else if (product_stringValue == "Universal Online Banker") {
} else if (product_stringValue == "Corporate Banking") {
} else if (product_stringValue == "Universal Payments Platform") {
} else if (product_stringValue == "UP Immediate Payments") {
} else if (product_stringValue == "Issuer" || product_stringValue == "Acquirer" || product_stringValue == "CardLinK" || product_stringValue == "Interchange" || product_stringValue == "OM - Open Messaging") {

or I need a custom listener with the same functions: add attachments and html format.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you