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

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

Automatically assign particular user as a reporter

On issue creation I want to automatically assign the reporter with a specific person (i.e. not the person creating the issue), i,m trying to use script runner post function in create transition of workflow. I had a script that add particular user as watcher can any one modified the script to particular user assign to reporter.

Here the script below

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue

def userName = "user name"
def userManager = ComponentAccessor.getUserManager()
MutableIssue issue = issue as MutableIssue
def user = userManager.getUserByName(userName)

def watcherManager = ComponentAccessor.getWatcherManager()

watcherManager.startWatching(user, issue)


Thanks in advance


2 answers

1 accepted

0 votes
Answer accepted

Hi @siva boddu For this simple task , scripted post function is not required. 
simply use post function update issue fields . Select Reporter >> Add username 

For script runner :-


issue.reporterId = "xyz"



Hi @Vikrant Yadav thanks for the reply,

I tried update issue field in post function but it didn't see the reporter as an option in drop down.


Hi @siva boddu  Then simply use script post function add below script :- It should work.

You are right reporter is not avialable in Update issue field. 


issue.reporterId = "xyz"

 Scripted post function.PNG

Hi @Vikrant Yadav  i used above script in post function but no changes done in reporter

reporter script.png


Hi @siva boddu  I have tested the same on my side. It's working fine. Are you using it on Create Issue transiton ?

If yes, then move it below Create Issue event. 

Check project permissions as well


Hi @Vikrant Yadav  Yes, it's using on create transition and i move it below create issue event still no response in reporter field. Please let know where i did wrong.


Hi @siva boddu  Above script works for other transitions. For Create Issue use below script :- 


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Level
import org.apache.log4j.Logger

def myLog = Logger.getLogger("com.onresolve.jira.groovy")

def user = ComponentAccessor.getUserManager().getUserByName("vikrant-yadav2")


 Hope it works for you. 

Keep it above Create Issue. 

Hi @siva boddu Is it works for you ? 

Let me know the result.

Hi @Vikrant Yadav ,

issue.reporterId = "xyz"

 The above script works for me and it used in script runner post function create sub task. I used that script in create sub task in script runner.

Thank you very much for your help.



@siva boddu Cool! Glad to hear it works for you.  :)

Kindly mark the solution as Accepted. It helps other users having same problem. 



Hello Siva,

What about something like:

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.util.UserManager

IssueManager issueManager = ComponentAccessor.getIssueManager();
MutableIssue issue = issueManager.getIssueObject("DEMO-1");
UserManager userManager = ComponentAccessor.getUserManager()
def issueReporter = userManager.getUserByName("charlie")
issueManager.updateIssue(issueReporter, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Please let us know how it goes!



Hi @Hyrum Steffensen _Appfire_ thanks for the response,

I tried your script and it throws the following error log


The following log information was produced by this execution. Use statements"...") to record logging information.

2021-06-21 23:21:46,764 ERROR [workflow.AbstractScriptWorkflowFunction]: *************************************************************************************
2021-06-21 23:21:46,764 ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: NMS-77233, actionId: 1, file: null
java.lang.NullPointerException: Cannot invoke method setReporter() on null object

Please let me know where to change script 


Hello Siva,

I believe the problem is this line:

MutableIssue issue = issueManager.getIssueObject("DEMO-1");

You must specify an issue key that exists on your system instead of "DEMO-1". This may also work:

MutableIssue issue = issue as MutableIssue

Please note that you must also change this line to accept a username of a user that exists on your system.

def issueReporter = userManager.getUserByName("charlie")



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

49 views 0 6
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