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
1
[usr]
[usr]
issue-1
false
false
However if I run this in other transition it works.