Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Grrovy Scirpt to add user to Watcher List

HI,

Using the below script to add an user to watcher list using Script runner in the issue Create PostFunction

import com.atlassian.jira.ComponentManager

ComponentManager componentManager = ComponentManager.getInstance()
def watcherManager = componentManager.getWatcherManager()
def userManager = componentManager.getUserUtil()

def watchUsers = {usernames ->
usernames.each { def user=userManager.getUser(it) watcherManager.startWatching(user,issue.getGenericValue()) }
}

def users = ["X"]
watchUsers(users)

However, I find the below errors in my log file

at java.lang.Thread.run(Thread.java:662)
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: watcherManager for class: com.atlassian.crowd.embedded.ofbiz.OfBizUser
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
	... 185 more

3 answers

1 accepted

0 votes
Answer accepted

Anyone can help ?

ANother clue is that this script works on the Script Console , but in the post script function it fails

Looks like this thread is thread. This is urgent and needs some help

Updated version for JIRA 7.1.4:

 

 

import com.atlassian.jira.component.ComponentAccessor

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

 def watchUsers = {usernames ->
   usernames.each {
         def user = userManager.getUserByKey(it.toString())
         watcherManager.startWatching(user, issue)
      }
}

def users = ["user1", "user2"]
watchUsers(users)

tested on 7.2.0 . It works as expected! Thank you

->

 In Jira Server 7.3.0 shows a problem with that symbol '-' 

Can you tell me what changed? I want the same code to work for the new version of jira SD.

@Stefani Kaimakliotou were you able to solve that issue?  Thanks!

We upgraded to server 7.5 and chose not to use the addition of the user to the watchers list. I found another way solving my case. Thanks a lot. 

Like Alibek_Malikov likes this
Like mani@123 likes this

Had to add this to make it work, but atlast it is working as expected

package com.onresolve.jira.groovy.canned.workflow.postfunctions

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

490 views 6 12
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you