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.
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:
string [] h = fieldHistory(key,
"assignee"
);
string a;
if
(isNotNull(h[
1
])) {
a = h[
1
];
}
else
{
a = h[
3
];
}
sendEmail(
a
,
"teamleader1"
,
"Assignee changed"
,
" Assignee for issue:" + key + "has changed to " + assignee
);
You can find more info on sendEmail method here:
Hello @Alexey Matveev
Thanks 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 Updated
def field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "assignee"}
// Gather old field value
def old_field_value = field.oldstring
// Gather new field value
def new_field_value = field.newstring
def 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still i am facing same issue .please suggest any one ,how we can do using script runner plugin
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.