script runner function failed on inline script

Hi ,

I am using Custom script in post-function as Inline script to add watchers in create Issue Transition, Inline script does not show any error while saving , but while creating  new ticket it is throwing error in the atlassian-jira.log .

Do i need to do something else for this to get work , kindly help

2016-05-17 19:08:16,825 http-nio-8080-exec-17 ERROR vijay.sridhar 1148x147845x1 t4vsbz secure/CreateIssueDetails.jspa[c.o.s.jira.workflow.ScriptWorkflowFunction]***************************************
2016-05-17 19:08:16,900 http-nio-8080-exec-17 ERROR vijay.sridhar 1148x147845x1 t4vsbz /secure/CreateIssueDetails.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: <i nline script> java.lang.NullPointerException


import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.util.UserManager;

def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def watchUsers = {usernames ->
usernames.each {
def username = userManager.getUserByKey(it.toString())
watcherManager.startWatching(username, issue)
def grp_users = ["n26_cust1", "n26_cust2","n26_cust3","n26_cust4","n26_cust5"]




1 answer

1 accepted

0 votes
Accepted answer

Can you confirm if you put the post-function as last one?

Thanks , it's working ..

what variable should  i use for adding the group ?

I dont get it, do you want to add a group to the watchers list? It is not possible. From the code i see you trying to add a list of users as watchers. This should be fine. Loop through the list and add them individually.

Thanks . @Vijay Khacharia

Tried to add Users in Particular group to be added as watchers ,So that when ever user created or deleted in JIRA does not require changes @ script level .


you can get the users from a group with

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,291 views 5 10
Read article

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