How add watchers in scriptrunner?

Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2022

Hello everyone! I have a code which add watchers in issue. 
but now I need to add a user only if the task : task type is "my task type" and it has a field "my cf select list" and the option "Yes" is selected there. Please tell me how can I do this? Thank you.

import com.atlassian.jira.component.ComponentAccessor

def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()

def watcher = ["username1","username2"]

watcher.each{userName->
def user=ComponentAccessor.userManager.getUserByName(userName)
watcherManager.startWatching(user, issue)
}

0 answers

Suggest an answer

Log in or Sign up to answer