I'm trying to modify the built in script "send to custom email to accept a addresses inserted into some customfield in Email CC.
how can this be done?
in this https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions documentation he tells that i can add
Email email =
new
Email(
"someuser@example.com"
)
// Set the TO address, optionally CC and BCC
some more examle? someone has modified the default script ?
I had a quick peek of the API here:
http://docs.atlassian.com/jira/latest/com/atlassian/jira/mail/Email.html
The below should give you what you're after:
Email(String to) Constructor specifying only the recipient. |
Email(String to, String cc, String bcc) Constructor including cc and bcc addresses. |
Are you familiar with how to pull values from a custom field to populate the CC field?
tnks
to modify the built in script i've to hack the library then? can't i add somewhere else the script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hmm ... it won't be as easy as changing a single line of code if you modify the built in script. You'd also need to create an input field for the CC line similar to how the TO input field exists, and who knows how you'd modify the behavior of the plug in with your changes. If you have some programming experience, I'd suggest creating a custom script. If you have none, .. well .. see if you can borrow a programmer. here's an example of a script that I use that sends emails to certain users when all tasks for a parent issue are done. Dissect and modify if you wish:
import org.apache.log4j.Category import com.atlassian.jira.ComponentManager import com.atlassian.mail.server.managers.OFBizMailServerManager import com.atlassian.mail.server.SMTPMailServer import com.atlassian.jira.mail.Email import com.atlassian.mail.queue.SingleMailQueueItem import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.properties.APKeys log = Category.getInstance("com.onresolve.jira.groovy.TicketWatcher") log.setLevel(org.apache.log4j.Level.WARN) log.debug ("---- Ticket Watcher script running ----") def sendEmail = true issue.getParentObject().getSubTaskObjects().each { t -> log.debug ("Analyzing $t") if (!t.getStatusObject().getName().equals("Done")) { sendEmail = false log.debug ("$t is still open. Do not send email.") } } if (sendEmail) { // configure email def projectManager = issue.getProjectObject().getLead().emailAddress def baseURL = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL) def issueURL = baseURL + "/browse/" + issue def parentURL = baseURL + "/browse/" + issue.getParentObject() log.debug ("address: $projectManager") log.debug ("base URL: $baseURL") log.debug ("issue URL: $issueURL") log.debug ("parent URL: $parentURL") OFBizMailServerManager mailServerManager = componentManager.getMailServerManager() com.atlassian.mail.server.SMTPMailServer smtp = mailServerManager.getDefaultSMTPMailServer() Email email = new Email(projectManager) email.setFrom(smtp.getDefaultFrom()) email.setSubject("Ticket ${issue.getParentObject()} Requires Review") email.setBody("The last open task (<a href=\"$issueURL\">$issue</a>) for ticket <a href=\"$parentURL\">${issue.getParentObject()}</a> was just closed. Please review <a href=\"$parentURL\">${issue.getParentObject()}</a> to determine if it should also be closed.") email.setMimeType("text/html") // send email SingleMailQueueItem item = new SingleMailQueueItem(email) try { ComponentAccessor.getMailQueue().addItem(item); } catch (Exception e) { log.warn("ERROR SENDING TICKET WATCHER EMAIL", e); } } log.debug ("---- Ticket Watcher script ended ----")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i've duplicated the send email, and modified adding another fields.
the problem is that i need to rebuild the jar i suppose
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
tnks
to modify the built in script i've to hack the library then? can't i add somewhere else the script?
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.