bug to remove watcher in create transition?

I am trying to remove watchers in the create transitions as users are automatically added as watchers when they create issue but my script does not seem to work.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def watcherManager = ComponentAccessor.getWatcherManager()
def issueManager = ComponentAccessor.getIssueManager()
Locale en = new Locale("en");
def watchers = watcherManager.getWatchers(issue,en)
def issWatchers = issueManager.getWatchersFor(issue)
log.error watcherManager.getWatcherCount(issue)
log.error watchers
log.error issWatchers
log.error issue
log.error watcherManager.isWatching(watchers[0],issue)
watchers.each {usr ->
watcherManager.stopWatching(usr, issue)
log.error watcherManager.isWatching(watchers[0],issue)

In the log I manage to get a watcher count and the user but the isWatching is giving a false return, is this a bug which resulted in this script not working?

the log returned this



However if I run this in other transition it works.

1 answer

0 votes

I have a feeling that auto-watch watchers are added later in the creation of the issue - your script is running at a time when the issue knows it is going to have watchers, but they aren't actually on the issue yet.

A better option maybe just to ask users to unset their autowatch flag if they don't want to be added.

But, have a look at the order of post-functions (if you're unsure, show us the order you have them in on the create transition)

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,755 views 11 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