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

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
4,558,559
Community Members
 
Community Events
184
Community Groups

How to set watcher based on custom field with Scriptrunner

Edited

Hi Guys,

today is the first-time that I'm attempting to use scriptrunner. Being someone thats never coded before, its proving to be an interesting challenge.

The user requirement should be easy,

1 When customfield Severity -cf[11807] = High

2 Add the JIRA group "TSM Managers" to the watchers 

My idea, is to add the script into the post function for the workflow.

Sounds simple and probably is when you understand how scriptrunner works.

Thanks for your help.

Paul 

 

 

 

 

 

 

 

1 answer

0 votes
Alexey Matveev
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.
Apr 16, 2018

You can not add groups as watchers. You can add only users.

You should still be able to extract the users from the group and add them to the watchers list.

Alexey Matveev
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.
Apr 16, 2018

Yes, you can do it. You can find it here:

https://community.atlassian.com/t5/Marketplace-Apps-questions/Get-the-members-of-a-group/qaq-p/443779

You can find how to add users as watchers here:

https://community.atlassian.com/t5/Marketplace-Apps-questions/Grrovy-Scirpt-to-add-user-to-Watcher-List/qaq-p/178738

I guess, you have everything you need to write your script.

Thanks Alexey,

As we only have x3 users whom need to be notified when the ticket severity is high,  we decided to hardcore them to the watchers list.

 Run a Groovy script against the current issue:

import com.atlassian.jira.component.ComponentAccessor
 
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()

def user1 = userManager.getUserByName("arey")
def user2 = userManager.getUserByName("seboursi")
def user3 = userManager.getUserByName("vrakotom")
def Sev = issue.get("customfield_11834")

if(Sev == "High") {
watcherManager.startWatching(user1, issue)
watcherManager.startWatching(user2, issue)
watcherManager.startWatching(user3, issue)

 

Thanks for your help.

Now Ive been asked to setup a NEW "calculated field" which requires a script that is above my basic coding levels!

Cheers,

Paul 

Alexey Matveev
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.
Apr 25, 2018

What kind of calculated field?

It shows that it is missing a } at the end of this but when I put that it causes a bunch of other errors?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events