Auto add watchers on issue creation?

Marty Williams March 3, 2016

Trying to get a group of watchers auto added when certain issue types are created. So JIRA can send out notifications to relevant parties. 

Are there simple conditions or post functions that can accomplish this?

TIA.

3 answers

1 vote
Vinay Shekar S February 28, 2020

This can be achieved by adding custom script postfunction on "Create Issue" workflow transition.

Follow below steps:

1. Add a Post function

2. Select "Script Post-Function [ScriptRunner]"

3. Select "Custom script post-function"

4. Add below code

========================================

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue


def userName = "username" // name of the user
def userManager = ComponentAccessor.getUserManager()
MutableIssue issue = issue as MutableIssue
def user = userManager.getUserByName(userName)

def watcherManager = ComponentAccessor.getWatcherManager()

watcherManager.startWatching(user, issue)

=========================================

5. Don't forget to move this postfunction below "Creates the issue originally"

PrerequisitesScriptRunner app from Atlassian MarketPlace

Sayan Kaiser June 11, 2020

Thanks Mate it works like a charm

1 vote
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
March 3, 2016

Update issues post function from Update on Transition for JIRA can be used. You can condition (using simple regex pattern matching) the update based on the issue types you want to have this happen for. Then you provide the watcher list in the Watchers field.

Dilyara Saetova January 11, 2018

I don't see how post function can be used for this purpose - there are only 2 choises: Update Issue Status and Update Issue Field, and non of them can be used to add watchers to an issue.

Watchers - is not a field.

1 vote
Jim Constant March 3, 2016

Marty,

You might try creating a filter, share it, and then those interested people can subscribe to it. Here's one I create to get a notification each morning with a list of issues added in the past day. You could modify it to look for the issue types you want and it might work for you:

project = "Your Project" AND issuetype in (Defect, Epic, Story) AND created > -1d

HTH,

Jim

Suggest an answer

Log in or Sign up to answer