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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,239 views 14 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot