Hello, i get an error in logs my post-function (in Workflow)
my code :
import com.atlassian.jira.component.ComponentAccessor
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def watchUsers = {usernames ->
usernames.each {
def user = userManager.getUserByKey(it.toString())
watcherManager.startWatching(user, issue)
}
}
def users = ["n.lubyanskaya", "a.belyaeva","e.fedoseeva", "e.dushnova", "l.golovanova", "a.zaretskaya","v.moshkarova","a.zamekhovskaya","e.kozhukhova"]
watchUsers(users)
What could be the problem ?
logs:
2022-06-10 11:18:51,737 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,817 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,888 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,928 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,962 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
Hi @Alex Kindly use following script for adding multiple users as watcher, update usernames as per your requirement :-
Kindly move scripted post function after "Creates the issue originally." post function, if you are applying script on create issue transition.
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)
}
Thanks
V.Y
@Vikrant Yadav , thank you very much, everything works! Have a nice day! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You’re Welcome 😇 Have a great weekend
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.