Need to send notification to both old and new assignee when assignee has changed in jira
Hello,
You could do it with a scripting add-on.
For example, you could use the Power Scripts add-on.
https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview
If you change an assignee, the new assignee will receive an out of the box notification from Jira.
To send a notification to the previous assignee, you could create a listener on the Issue Assigned event and attach to this listener the following script:
"assignee"); string a; if(isNotNull(h[1])) { a = h[1];}else{ a = h[3];} sendEmail(a,<span> </span>"teamleader1",<span> </span>"Assignee changed", " Assignee for issue:" + key + "has changed to " + assignee);string [] h = fieldHistory(key,<span> </span>
"assignee"
);
string a;
if
(isNotNull(h[
1
])) {
a = h[
];
}
else
{
3
sendEmail(
a
,<span> </span>
"teamleader1"
"Assignee changed"
,
" Assignee for issue:" + key + "has changed to " + assignee
You can find more info on sendEmail method here:
<a href="https://confluence.cprime.io/display/SIL/sendEmail" target="_blank" rel="nofollow noopener noreferrer">https://confluence.cprime.io/display/SIL/sendEmail</a>
Hello @Alexey MatveevThanks for your reply .I tried through script runner post function to send an email .But getting error on sendEmail method .
import com.atlassian.mail.Email;import com.atlassian.mail.server.MailServerManager;import com.atlassian.mail.server.SMTPMailServer;import com.atlassian.jira.component.ComponentAccessor;
def subject = "Insert text here for ${issue.key}"def body = "Hi ${issue.assignee.displayName} \n\nNow that XXXXX has been released, please complete XXXXX for the following issue: https://XXXXXXX/${issue.key} - ${issue.summary}. \n\n"// Gather changed field at the Issue Updateddef field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "assignee"}
// Gather old field valuedef old_field_value = field.oldstring
// Gather new field valuedef new_field_value = field.newstringdef emailAddr = old_field_value
def sendEmail(String emailAddr, String subject, String body) {SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();if (mailServer) {Email email = new Email(emailAddr);email.setSubject(subject);email.setBody(body);mailServer.send(email);} else {// Problem getting the mail server from JIRA configuration, log this error}}sendEmail (emailAddr, subject, body)
//Can not find matching method error is coming .Thanks in advance.
Still i am facing same issue .please suggest any one ,how we can do using script runner plugin
It looks like you're new here. Sign in or register to get started.