We have a customfield namely "Call Type". We need jira mail notication whenever a value of this customfield is changed. I have used following script in "behaviour" for this purpose but it is not working -
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import org.apache.log4j.Category
FormField "Call Type" = getFieldById(fieldChanged)
ComponentManager componentManager = ComponentManager.getInstance()
MailServerManager mailServerManager = componentManager.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email("someuser@example.com") // Set the TO address, optionally CC and BCC
email.setSubject("Blocking issue raised by ${issue.getReporter().getFullName()}: ${issue.summary}") // todo: check the subject value
String content = "Construct your body here."; //TODO: Set email's body.
email.setBody(content)
mailServer.send(email)
}
else {
log.error("No SMTP mail server defined")
}
It gives us below mentioned error -
Compilation failure: startup failed: Script1.groovy: 14: unexpected token: Call Type @ line 14, column 11. FormField "Call Type" = getFieldById(fieldChanged) ^ 1 error
Could you please help us regarding this ?
Regards
Sumit