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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

97 views 1 0
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