Hi,
We have a script runner in place, something which I have inherited, which already adds users as watchers, but is also including a few old disabled users who are members of a group, from when jira was initially setup using Jira Internal Directory, before it was integrated with Azure AD. The simple fix would be for me to remove the user from the group, but I cannot remove user from the groups, and encounter an error
"You cannot remove a group from this user as it is not visible to you."
Therefore, I would like to modify the script to only add those watchers where the account is enabled or ignore disabled accounts if they exist in the group. ("techsupport")
The code is below, I can make sense of what its doing, but not being a coder, a little help on how to achieve this would be very appreciated.
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
IssueManager issueManager = ComponentAccessor.getIssueManager();
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
Issue issue = event.issue;
if (ComponentAccessor.getGroupManager().getUsersInGroup("support").contains(issue.reporter)) {
ComponentAccessor.getGroupManager().getUsersInGroup("techsupport").each {
def user = userManager.getUserByName(it.getName())
if (user) watcherManager.startWatching(user, issue)
}
}
Thanks in advance