Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner Listener add User Picker field name as Watcher


Just wanted to share the code that @Benz Kek _Adaptavist_ helped me with for creating a listener that adds a user who is added to a jira issue in a user picker, as a watcher of the issue. As always the support from the Adaptavist team is fantastic - thanks again Benz.

We have a number of different people working on various Jira issues who are added under different userpicker custom fields by their managers, previously the manager would have to remember to manually add them as watchers.

Examples are 'photographer' or 'stylist'

The code below is the script inserted in a SR Listener, fired from (in my case) the' issue updated' event

It will only add the user as a watcher if have not already been added


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def watcherManager = ComponentAccessor.watcherManager
def userManager = ComponentAccessor.userManager

def issue = event.issue
def singleUserPickerFieldName = "User Picker Custom Field"
def singleUserPicker = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName(singleUserPickerFieldName).first()
def user = (ApplicationUser) issue.getCustomFieldValue(singleUserPicker)

def currentWatcherUsernames = watcherManager.getCurrentWatcherUsernames(issue)
if (!(user.username in currentWatcherUsernames)) {
watcherManager.startWatching(user, issue)


1 comment

Nice. I can see this being very useful!


Log in or Sign up to comment