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

Adding usert to watchers Post-Function

pawel.gryzewski July 10, 2018

hi.

i've found that script on your side (https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html) i'm trying to use clone issue and link post-function and i need to add one custom user to watchers. I've tied to use script but id doesn't work:

import com.atlassian.jira.component.ComponentAccessor

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

doAfterCreate = {
def userKeyToAddAsWatcher = "anuser"
def watcher = userManager.getUserByKey(userKeyToAddAsWatcher)

if (watcher)

{ watcherManager.startWatching(watcher, issue) }

else {
log.warn("User with key: $

{userKeyToAddAsWatcher}

does not exist therefore would not be added as a watcher")
}
}

 

Do you know how to resolve this?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
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.
July 10, 2018
pawel.gryzewski July 11, 2018

Hey

Wow that was a quick reply:)

 

Tkanks - i've made it work

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.
July 11, 2018

You are welcome!

TAGS
AUG Leaders

Atlassian Community Events