Hello All,
I have used below script in script listeners to disable autowatcher for reporters for a particular project.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.preferences.PreferenceKeys
def userManager = ComponentAccessor.getUserManager()
def preferencesManager = ComponentAccessor.getUserPreferencesManager()
userManager.getUsers().each {
user ->;
if (! preferencesManager.getPreferences(user).getBoolean(PreferenceKeys.USER_AUTOWATCH_DISABLED)) {
preferencesManager.getPreferences(user).setBoolean(PreferenceKeys.USER_AUTOWATCH_DISABLED, true)
}
}
But it is disabling for all the projects. when user creating issues in other project they are not automatically added to the watcher field.
Is it possible to limit disabling autowatcher for reporters for a single project??
Thanks in Advance,
Manikanta
because it's a user's setting, so it has a global context, you either autowatch issues or not.
I think you can rewrite listener to remove a reporter from watchers and limit the projects you want via the listener's context
The listener might look like this(on IssueCreated event):
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue
def watcherManager = ComponentAccessor.watcherManager
def watchers = watcherManager.getWatchersUnsorted(issue)
def reporer = issue.reporter
if (reporter in watchers) {
watcherManager.stopWatching(reporer, issue)
}
Hi Turov,
Thanks for the reply!
I have added the script in the script listeners for issue created event. However, still autowatch is disabled for all projects.
It is showing below error in line 7 & 8:
Below error in the logs:
2019-08-26 14:08:03,302 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-08-26 14:08:03,302 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script> groovy.lang.MissingPropertyException: No such property: reporter for class: Script338 at Script338.run(Script338.groovy:7
Thanks in advance,
Manikanta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.