How to add the PM as a Watcher for all new Issues created?

Nick July 31, 2018

Is there a way to do this with ScriptRunner?

2 answers

0 votes
JohnsonHoward
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2018

Hi Nick,

Alexey is right this can be done without ScriptRunner. However if you want to use ScriptRunner so you can add some more customisation you could do something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager


Issue issue = event.issue
def watcherManager = ComponentAccessor.getWatcherManager()
def roleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectRole = roleManager.getProjectRole("PM")
ProjectRoleActors actors = roleManager.getProjectRoleActors(projectRole,issue.getProjectObject())
def pms = actors.getUsers().toList()
pms.each{
watcherManager.startWatching(it, issue)
}

Add that code as a Script Listener and tell it to listen to the issue created event. 

Thanks

Johnson Howard (Adaptavist)  

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2018

Hello,

You can get this behaviour out of the box. If you add a watcher to an issue, this user gets notifications on issue events. You can add a new role and add the required user to this role. After it in the project notification scheme you can set for this role the same events as for watchers. In this case all users will get notifications like watchers.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events