Mobility for Jira

Receive Push Notification for Issue Creation

If you would like to receive push notifications for new issue that are created, you have the following options:

  1. Receiver is selected as reporter on issue creation

  2. Receiver is the default assignee in Jira project

  3. Make receiver a watcher on issue creation


In this article we explore how you can make a user or group of users a watcher so that they receive push notifications on issue creation. Here are the steps:

  1. Create a post-function in your workflow for the create transition

  2. The post-function needs to be executed before firing the event

  3. Add a groovy script to the post-function that assigns watchers


image001.png


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.util.UserManager
WatcherManager watcherManager = ComponentAccessor.getWatcherManager()
UserManager userManager = ComponentAccessor.getUserManager()
def watchUsers = {usernames ->
    usernames.each {    
        watcherManager.startWatching(userManager.getUserByName((String)it), issue)
    }
}
 
def users = ["USERNAME","USERNAME2","USERNAME3"]
watchUsers(users)