Using Behaviours plugin to set assignee from issue type

Hi everyone

Simple question I think but I can't get it to work.

I would like to use the behaviours plugin from ScriptRunner to set and lock the assignee when the user selects a specific issue type and of course unlock it again when any other issue type gets selected.

I created a behaviour and mapped it to the desired project and issue type and then created an initialiser function like so.

if (getActionName() != "Create Issue")
    return // not the initial action, so don't set default values


However, the assignee remains on 'automatic' and the field does not get locked when I create a new issue.

What could be the issue here? Why does the initialiser not run?

Thanks for any help.


1 answer

Hi Marius

Sorry for the late response, you can try something like 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.atlassian.jira.issue.IssueFieldConstants.*
import groovy.transform.BaseScript

def assignee = getFieldById(ASSIGNEE)
def issueTypeId = getFieldById(getFieldChanged()).getValue() as String
def issueTypeName = ComponentAccessor.getConstantsManager().getIssueType(issueTypeId).name

if (issueTypeName == "Bug") {
    assignee.setFormValue("admin") //set user using the username
else {

You have to attach this behaviour on at the Issue Type field.

Please let me know if this does the trick.

Kind regards, Thanos

Hi Thanos,

I tried out the code for doing the following:
If the Checkbox "sofort abschließen" is checked the assignee should be set to the reporter and to read only too.

The user I tested with had all needed permissions. The Behaviour was attached to a Checkbox Customfield (cfAbschliessen in the Code).

As a result the assignee field was only set to read only but the user did not change.
Alternatives I tried you can see as comment lines in my code. No one of this lines worked.

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def assignee = getFieldById(ASSIGNEE)
def cfAbschliessen = getFieldById(getFieldChanged()).getValue() as String

if (cfAbschliessen == "sofort abschließen")
//assignee.setFormValue("admin") // usage of the username


Can you give me a hint how I can change the assignee?


King regards

I'm having the same issue as Roman. The field does not show my specified user and ist still set to 'Automatic'. I tried using debug messages and apparently, the value of the variable assignee changes but it has no effect on my screen or the assignee after clicking Create. grafik.png


Nevermind. I figured it out. The user has to be someone with the permission "assignable user" in said project and issuetype. I was testing with myself but forgot that.

However, resetting back to "Automatic" after changing the issuetype does still not work :(

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


123 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