Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage


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 

2 answers

1 accepted

1 vote
Answer accepted

Listener would be best, because it can update the watchers on edit as well as transition.

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?

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.

Like Stanislav likes this

@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( == "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

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you