Im new to scriptrunner
Add user (Tom Thomas) as a watcher on an issue if assignee is (John Johnson) in a certain project, for example project ABC. Where i should write script ? Behaviour, post function, listeners ?
If you can provide me with a script it would be perfect
Listener would be best, because it can update the watchers on edit as well as transition.
https://library.adaptavist.com/entity/automatically-add-watchers-to-newly-created-issues
should get you started. You'll want to change the events it's looking at (create, update, assign and possibly transition if you change assignees during transitions), and add a bit of logic for "if user X then add watcher Y", but most of what you need is there.
if assignee was added not at the creation of issue but later in the workflow or have been changed will it work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's what the listener is for - it can catch "edit" and "assign" events where the assignee may be changed.
So yes, it can pick up the current assignee whenever it changes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- What do you think about this code will it work
import com.atlassian.jira.component.ComponentAccessor
def watcherManager = ComponentAccessor.watcherManager
def userManager = ComponentAccessor.userManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
if(loggedInUser.name == "John Johnson") {
def watchUsers = { usernames ->
usernames.each {
def user = userManager.getUserByName(it)
watcherManager.startWatching(user, issue.genericValue)
}
}
def users = ["tthomas"] // use Tom Thomas' username not full name
watchUsers(users)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This seems to have been continued here:
https://community.atlassian.com/t5/Jira-Software-questions/Scriptrunner-post-function-or-behaviour/qaq-p/1711254
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.