We want to limit the creation of all issue types except for one. We have a separate workflow for the issue type that the users are allowed to create.
I tried solving this with a custom script validator (ScriptRunner) on the creation transition, which I based off of an example script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
// the name of the project role
def roleName = '_project_admin'
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def role = projectRoleManager.getProjectRole(roleName)
projectRoleManager.isUserInProjectRole(issue.reporter, role, issue.projectObject)
Unfortunately, this doesn't work right. When I try to create an issue with this workflow with a test user that doesn't have the role the issue is still created. I don't know anything about GroovyScript - what is going wrong here?