ScriptRunner Groovy Script based on issue type

Good morning!

I am new with groovy / scriptrunner and I am having difficulties in writing a script. The request is to use a post-function in the Create transition workflow to re-route tickets to a specific user when issue type = ‘Incident’ and Component is not set.

My idea is to use the inline postfunction option to achieve this. Can anyone help with the script to do this? Thanks.

1 answer

Hi Daniel,

To do this using a post-function you wil need to add this code:



import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

UserManager userManager = ComponentAccessor.getUserManager();
MutableIssue issue = issue
if( == "Incident" && issue.getComponents().size() == 0 ){




Replace the 'Test' user with whomever you would like to set the issue to. The post-function will need to appear first in the list for this to work. 

You could also do this as a behaviour on the 'Assignee' field and change it depending on the form field value of componant and issue type. 

Let me know if this is what you were looing for, or if I have misundertood and you need some other solution.


Johnson Howard

Thanks for your prompt response Johnson. I am still to test this as our associates have a new type of request now.


As soon as I have this tested, I will update this thread. Thanks.

Any update on this Daniel?

Good morning Johnson,


Sorry for the late reply. Just able to test it now in our non-prod instance.

I am attaching three screen shots with the error messages. Hope you can get them.

Any suggestions? Thanks.



What version of JIRA and ScriptRunner are you using?

JIRA is 6.4.12

ScriptRunner is



Try with just:

issue.assignee = userManager.getUserByName()

I still get errors. Attached. Thanks.


If you update your JIRA and Scriptrunner, the previous code will work.

I have a similar case,  I want to copy custom field value of one issue type to all other issues of the project.


We have Issue type "Project info"  and we created one issue of "Project info" type per project to maintain all project related information.

So anything changes in the project we update the respective field on of  project info issuetype of that project.

Now I want to copy one of the custom field value of project info issue type to all other issue of that  project.


Can anybody help me with this?


Thanks in advance.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


117 views 0 3
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