Currently, we're using Script Runner Listeners to send emails on certain events. We have 15 of these created -- but they just handle different versions of the same two events.
We would be able to get this down to 2 listeners if I could do the following:
To addresses (or To issue fields):
<% out << (issue.priority.name == "P1 - Critical" ? "role:cellphonepager" : "role:projectlead") %> or
<% if(issue.priority.name == "P1 - Critical") { out << "role:cellphonepager" } else {out << "role:projectlead"} %>
We already use a lot of these for Subjects and the email template, but it didn't work when we tried to use this to address the email. Any suggestions how to accomplish?
Thanks, -Ed
Henning, that was a perfect suggestion. Thank you!
Inside of our Script Runner Event Listener, we set the 'To issue fields' to 'customfield_10700'. Custom Field ID 10700 is a scripted field:
//THIS CUSTOM FIELD CONTAINS THE TARGETS FOR OUTGOING SMS ALERTING: //P1 -> oncall all the time //P1 -> primary-secondary during biz hours //P2 -> primary-secondary during biz hours //P3, P4 -> no SMS sent //ESCALATED -> escalatedpager@spkaa.com import com.atlassian.jira.project.Project import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.security.roles.* Date now = new Date()
//create empty notifyList string def notifyList = ""
//Create new objects used for determining ticket project and roles and roleActors (users in role)
Project myProject = issue.getProjectObject()
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager cfManager = componentManager.getCustomFieldManager()
CustomField cf = cfManager.getCustomFieldObject(10207) //Escalation Status custom field
ProjectRoleManager roleManager = componentManager.getComponent(ProjectRoleManager.class)
ProjectRole role = roleManager.getProjectRole("Primary-Secondary-Email")
ProjectRoleActors actors = roleManager.getProjectRoleActors(role, myProject)
//For a P1 during business hours, add Primary-Secondary-Pager and ONCALL
if ((now.hours >= 9) && (now.hours < 18) && issue.priority.name.contains("P1")) {
role = roleManager.getProjectRole("Primary-Secondary-Pager")
actors = roleManager.getProjectRoleActors(role, myProject)
actors.getUsers().each { i ->
notifyList += i.getEmailAddress() + " "
}
notifyList += "emergencypager@spkaa.com "
}
//For a P1 AFTER business hours, add ONCALL
if ((now.hours < 9) && (now.hours >= 18) && issue.priority.name.contains("P1")) {
notifyList += "emergencypager@spkaa.com "
}
//For a P2 during business hours, add Primary-Secondary-Pager.
if ((now.hours >= 9) && (now.hours < 18) && issue.priority.name.contains("P2")) {
role = roleManager.getProjectRole("Primary-Secondary-Pager")
actors = roleManager.getProjectRoleActors(role, myProject)
actors.getUsers().each { i ->
notifyList += i.getEmailAddress() + " "
}
}
//If the ticket is ESCALATED, include escalate@spkaa.com
if (issue.getCustomFieldValue(cf).toString() == "Escalated") {
notifyList += "escalatedpager@spkaa.com "
}
return notifyList
We use this to ensure that the P1 and P2 helpdesk tickets notify the correct people - and limit the notifications after business-hours. We also use this with the Escalate Ticket built-in script as part of our "Escalation System" in case anything gets missed.
The //For a P2 during... block is a good example of getting all email addresses for a ticket's project role named "Primary-Secondary-Pager", in case someone is looking for just that piece.
Maybe you could create a scripted custom field which "calculates" to correct receiver for the issue and than use this field as "To:".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.