Automatic notification based on Priority

Is it possible for JIRA to send notification to a group of users or add a group of users to the watchers list if an issue has been created with a certain priority?

3 answers

It might be easier to set up a filter and have the users subscribe to it. This works well for escalation scenarios.

Yes, you can develop groovy scirpt. Sample is below. This has to go on issue create and generic event to make it work under script listener of add-on

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.event.issue.AbstractIssueEventListener

import com.atlassian.jira.event.issue.IssueEvent

import com.atlassian.jira.issue.Issue

import org.apache.log4j.Logger

import com.atlassian.jira.ComponentManager

import static org.apache.log4j.Level.DEBUG

class TaskListener extends AbstractIssueEventListener {

Logger log = Logger.getLogger(TaskListener.class)

def groupManager = ComponentAccessor.getGroupManager()

def watcherManager = ComponentAccessor.getWatcherManager()

def userManager = ComponentAccessor.getUserManager()

@Override

void workflowEvent(IssueEvent event) {

Issue issue = event.getIssue();

log.setLevel(DEBUG)

log.debug "Event: ${event.getEventTypeId()} fired for ${issue} and caught by TaskVersionListener"

def priority = issue.getPriorityObject().getName()

log.debug priority

def issuestatus = issue.getStatusObject().getName().toUpperCase()

log.debug "status of issue" + issuestatus

def criticalUser = userManager.getUserObject("user1")

def seriousUser = userManager.getUserObject("user2")

switch (priority) {

case 'Critical':

if (!issuestatus.equals("xxx")){

watcherManager.startWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

}

break

case 'Serious':

if (!issuestatus.equals("xxx")){

watcherManager.startWatching(seriousUser, issue.genericValue)

watcherManager.stopWatching(criticalUser, issue.genericValue)

}

break

case 'Important':

watcherManager.stopWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

break

case 'Minor':

watcherManager.stopWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

break

}

}

}

please let me know if mentioned code has helped you.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,934 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot