Adding Group from a custom filed to watchers list

I'm totally new to JIRA and Groovy too. I'm looking for a script which can fetch the Group from a custom filed and add to watchers list. Can someone help me with that?

4 answers

Hi Nic,

Thanks for the information. Yes, your suggestion will be goog enough for me. Thank you!

0 vote

You can't.

A group is a group, a watcher is a user. The two objects are incompatible.

The best you can do is get the group, iterate through all the members to get the individual users and add each individual as a watcher - will that be good enough?

Nic,

Will you be able to help me with the code?

Have a look at the script-runner documentation really, as I'd encourage you to learn for yourself (and I've not written anything similar yet)

However, I'd think you'll need something like

import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.ComponentManager
def componentManager = ComponentManager.getInstance()
defwatcherManager = componentManager.getWatcherManager()
def groupValue = getCustomFieldValue("Group field name")
(This is the part I don't know off the top of my head - to find the list of users in the group
The code I've given here is based on something I did to add a single user custom field to the watchers)
for(user in listUsers) {
watcherManager.startWatching(user issue.getGenericValue())
}

To expand and help a bit on Nic's answer here is another question that has an answer from @Michal Orzechowski that I found helpful as well.  I didn't creat anything yet but I hopefully will.  If I get smothing that works Ill post it here as well.

The other Answers questions that has some good dev links in it to specifics.  

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Posted yesterday in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

40 views 0 5
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