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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Add watchers

Hi All

We have a custom field to store product information. Whenever a user creates an issue related to a bug, we hope to automatically add the corresponding leader as watchers according to the field value. I have looked at other documents in the community, but there seems to be no relevant solution

The jira we are using is the server version, and the corresponding Project automation does not have the option of managing watchers. I am trying to solve this problem using scriptrunner, but I am not sure how to get or assign the value to watchers

2 answers

1 accepted

0 votes
Answer accepted
Adrien Low _ServiceRocket_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 31, 2023

Hello @arno ,

If you could provide us with more information on your requirements, it would greatly help us to provide a better solution.

For example:-

  • Current Jira version
  • What has been implemented so far?

From what we can see, Jira Automation for Data Center does provide an action to manage Watchers:-

Screenshot 2023-10-31 170909.png

You should be able to manage your Watchers after configuring additional conditions.

If you would like to use ScriptRunner instead, you can configure a Custom script post-function [ScriptRunner] in your workflow with the below draft script:-

 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()

def productInformationCF = customFieldManager.getCustomFieldObject('customfield_xxxxx') //ProductInformation

def productInformationValue = issue.getCustomFieldValue(productInformationCF)

def user

if(productInformationValue.equals("A")) {
user = userManager.getUserByName('charlie')
} else if(productInformationValue.equals("B")){
user = userManager.getUserByName('alpha')
} else {
user = userManager.getUserByName('beta')
}

watcherManager.startWatching(user, issue)

Hope this helps.

Regards.

Hi @Adrien Low _ServiceRocket_ 

It works. Thank you for your help

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events