Hi,
I have "Valid warranty date" Date field when it lesser than 2 days than system's date (i mean when warranty date expiring in two days) it should trigger an email to specific user.
I have this following code but not triggering an email
Could you help me on this.
Thank u in advance
import com.atlassian.jira.component.ComponentAccessor
import groovy.xml.MarkupBuilder
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def warrantyField = customFieldManager.getCustomFieldObjectByName("Valid Warranty Date")
def warranty = issue.getCustomFieldValue(warrantyField)
def systemDate = new Date()
if(warranty < systemDate)
def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(prasadhattaraki@gmail.com)
email.setSubject(subject)
email.setBody(body)
mailServer.send(email)
log.debug("Mail sent")
} else {
log.warn("Please make sure that a valid mailServer is configured")
}
}