Restricting issue creation of certain Issue Types based on user project role

Hi Team,

I just want to know, if there is a way to restrict creation of an issue type based on the Project Role.

For example,

I have 3 roles in my project,

  • Project Role Admin
  • Project Role Developer
  • Project Role User

And i have the below issue types,

  • Story
  • Epic
  • Bug
  • Task

I want only Project Role Developers to be able to create only Bug issue type.

Please let me know incase of more information required.

Thank You,

2 answers

1 accepted

Hey Surender!

Thanks for raising this question! :D

To clarify, are you saying that you want to limit the options for Developers so that they can ONLY select the "Bug" issue type?

After doing some digging, I'm afraid I've come back with some info that's more disconcerting than I would have hoped. As it turns out, the Issue Type field is one of the only fields that, using a Behaviour, you can't manipulate the selectable options for. This has been a long-standing issue and is recorded in SRJIRA-1010.

Although that throws out the cleanest solution, you could still implement essentially the same functionality with a ScriptRunner Behaviour. For instance, you can still set the Issue Type field. So you could use a Behaviour to check if the user is a Developer and then automatically set the field to "Bug" and lock it so that they cannot change the Issue Type. The code to do this would look something like:

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

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

def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
log.warn("Thing: "+remoteUsersRoles)
//Set "Project Role Developer" to the name of the project role that you'd like to check for
if (remoteUsersRoles == ["Project Role Developer"]) {
def constantsManager = ComponentAccessor.getConstantsManager()
def bugIssueType = constantsManager.getAllIssueTypeObjects().find{ == ["Bug"] }
//Set the issue type to Bug and make it read-only

There is also an example of setting the Issue Type in our documentation here.

Let me know if this solution would work for you or if we need to explore some other avenue. Also, if you need help implementing the above Behavior, give me a holler. :D



0 vote
Peter DeWitt Community Champion Jan 09, 2018

@surender kallam, If you are using different workflows for each issuetype, you can use a validator on the issue creation link.  Jira suite utilities will allow you to validate against project roles.  Naked Jira may require specific user groups to be used.



Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

763 views 2 19
Join discussion

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