How to set watchers based on value of custom field (not use cf)


I need to set watchers on create when a single select list custom field value is being selected.

I tried to use "Set a field as a function of other fields" but got errors when tested several options

 How can that be done.

3 answers

1 accepted

This widget could not be displayed.

Hi Itamar,

It is not very difficult. First of all install Script Runner plugin. This is a powerful plugin which will be helfpful in the future. 

To add user to watchers use this:

import com.atlassian.jira.component.ComponentAccessor
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserObject("userid")
if (user) watcherManager.startWatching(user, issue.genericValue)

To get value from custom field use this:

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "customfield_name" );
log.warn ("value: "+ issue.getCustomFieldValue( customField_name))


Of course you need to be aware that you need to modify this code according to your requirement.

In case of any problem let me know smile

This widget could not be displayed.

Thanks Michal

Can you post the full script

If value is so and so, watchers x, x will be inserted?


This widget could not be displayed.

can u post the full script pleae

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

91 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you