I want to be able to send email notification on an update on a ticket when, along the assignee, I have also a custom user picker field called "Requirement Owner".
I dont know how to access the email field of that "Requirment Owner"
I started with this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail
def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)
def issueTypeName = event.issue.issueTypeObject.name
def customField = customFieldManager.getCustomFieldObjectByName("Requirement Owner")
if (issueTypeName == "Requirement" ) {
def emailAddress = issue.getCustomFieldValue(customField)?.get("1")?.value
log.warn("${event.issue.key}")
log.warn(event.issue.key)
if (emailAddress) {
def params = [
"issue" : event.issue,
(SendCustomEmail.FIELD_EMAIL_TEMPLATE) : "Issue ${event.issue.key} has been updated",
(SendCustomEmail.FIELD_EMAIL_SUBJECT_TEMPLATE): "New Issue Created ${event.issue.summary}",
(SendCustomEmail.FIELD_TO_ADDRESSES) : emailAddress,
(SendCustomEmail.FIELD_EMAIL_FORMAT) : "HTML"
]
def sendCustomEmail = new SendCustomEmail()
if (!sendCustomEmail.doValidate(params, false).hasAnyErrors()) {
sendCustomEmail.doScript(params)
}
}
}
Please help