I'm trying to add 1 user as a watcher on a post function once a ticket is created. I'm using script runner and this is the syntax I currently have:
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()
def user = userManager.getUserByName("jhobson1")
if (issue.Components.equals("DART")){
watcherManager.startWatching(user, issue) }
Essentially if the components system field equals "DART" the user should be added as a watcher. Unfortunately, it doesn't do anything.
Thanks for any help.