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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Restrict issue type to role or group (with or without scriptrunner)


We are using many issue types, but want role "service desk team" to view and create issue type "Incidents" only. The rest of the issue types should not be available, either to view in the create menu or anywhere else. It will just cause confusion.

I have tried the following script from the scriptrunner library, but get an error. Any ideas?


2 answers

1 accepted

Restrict issue types.PNGHi Hana,

This worked.

Now users in a given role have the issue types available to them restricted accordingly.

It was also very simple to implement.

Thank you


0 votes
Hana Kučerová Community Leader Feb 20, 2020

Hi @Mark Fallaize,

welcome to the Atlassian community!


Instead of ... (three dots) there should be listed some classes, which needs to be imported.

One of them would probablby be:

import com.atlassian.jira.component.ComponentAccessor

Also it looks like variable constantsManager is not defined, so you should add after line 5 (definition of projectRoleManager) line

def constantsManager = ComponentAccessor.getConstantsManager()

Would you please provide me url to the ScriptRunner Library, where you get the script? 

Thank you.

Hi Hana,

Thank you for your quick reply, I just returned back to office.

I used:

With your additions, I get the following error message:

The script could not be compiled: The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script91.groovy: 2: unexpected token: com @ line 2, column 8. static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE ^ 1 error </pre>.

script 2.PNG

Sorry but I am new to this code, what might be the issue?



Hana Kučerová Community Leader Feb 28, 2020

Hi @Mark Fallaize,

sorry for the late response.

Please add the word "import" before the word "static" on the second line.


I tried to write the script for you - unfortunately I'm not able to try it right now because of the problems with my test instance, but I believe it could work.

Basically the script just checks, if logged in user has project role Service Desk Team. If so, then the type field is limited to only Incident and set to read only. There are no changes for other users without role Service Desk Team.


import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)

def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name

if ("Service Desk Team" in remoteUsersRoles) {
    def availableIssueTypes = allIssueTypes.findAll { in ["Incident"] }

Hi Hana,

Thank you for trying. Unfortunately we get the following error:

groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getFieldById() is applicable for argument types: (java.lang.String) values: [issuetype] at 3.PNG

Hana Kučerová Community Leader Mar 03, 2020

Hi @Mark Fallaize,

to be honest - this is very strange. Would you please write me information, where exactly in your system do you have this code? Is it really saved as a Behaviours script? Thank you. 

Hi Hana,

Thank you for your reply.

The above errors were highlighted in the Scriptrunner console. I also tried it in the Script Editor with the same result.

Hana Kučerová Community Leader Mar 04, 2020

Hi @Mark Fallaize ,

thank you, now I understand, where the problem is. This script (and also the original one from the library) must be used in Behaviour, it won't work in "standard" ScriptRunner.

Please follow these instructions:

  1. In Administration of Jira click on Manage Apps -> Behaviours
  2. In the section Add Behaviour fill in some name and click on Add - new behaviour will be created
  3. In the row with newly created behaviour click on Add Mapping - now select all the projects, where you want to apply this restriction. You can also add Service Desk mapping, which means, that this restriction will be applied also when your team will try to create the issue from the portal.
  4. In the same row click on Fields - in the behaviour create initialiser and insert the provided code.
  5. Save the behaviour
  6. Test it :-)

Your settings should look something like this:behaviour.png

Anyone know how to get a 'not in' working? All I'm trying to do is to say, if the user is NOT IN "Users" role, basically the rest of the company, then restrict the issue type to Service Request, I'm using the template on the Behaviours site, but when I put in not in or != it doesnt work.


import com.atlassian.jira.component.ComponentAccessor

static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

// if the current user is in the Users role only, set the issue type to "Query", and lock it
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
if (remoteUsersRoles != ["Users"]) {
def constantsManager = ComponentAccessor.getConstantsManager()
def queryIssueType = constantsManager.getAllIssueTypeObjects().find { == "Service Request" }
getFieldById(ISSUE_TYPE).with {

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events