Restrict Issue Type Creation for Certain Users

Patrick Chen
Contributor
March 11, 2021

Hello, 

We're new to Jira Cloud coming from Jira Server. We have a Project with IssueTypes such as Story, Bug, Inquiry.

We have some users who we want to limit to Creating the Inquiry IssueType only.

How can this be achieved?

We have access to JMWE full plugin. We used to be able to use groovy script Validator on the Create transition to restrict it by checking if a user was in a restricted Role:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def roles = projectRoleManager.getProjectRoles(currentUser, issue.projectObject)

return roles.find { role -> role.name.equals("Software Support Analyst")} == null;

Any guidance is appreciated. 

2 answers

1 accepted

6 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 11, 2021

Hi @Patrick Chen ,

on Jira Cloud, you can use a Build-your-own Validator, but the script must be written using Jira's own Jira Expressions language.

The equivalent of the Groovy script you shared would be:

user.getProjectRoles(issue.project).some(pr=>pr.name == "Software Support Analyst")

To restrict the creation of issue to the Inquiry issue type for member of that project role, you could do:

!user.getProjectRoles(issue.project).some(pr=>pr.name == "Software Support Analyst") || issue.issueType.name == "Inquiry"
Patrick Chen
Contributor
March 12, 2021

Thanks David! We adapted the script you provided and used JMWE to successfully apply a Role based restriction on select Issue Type creation!

Like Stuart Capel - London likes this
Mitchell Meighen September 10, 2021

Awesome, Thank you Sir!

rbalamu2
Contributor
July 18, 2022

Hi @David Fischer ,

I want to restrict Epic creation based on project role.
I want only "Administrator" of that project should be able to create Epic. Is that possible?
For all the project I want to add this validator. Kindly help!

I am using JMWE plugin -> Build your own validator.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2022

Hi @rbalamu2 ,

this is almost exactly what was provided before... In your case, the script would be:

issue.issueType.name != "Epic" || user.getProjectRoles(issue.project).some(pr=>pr.name == "Administrator")
Like Goyal_ Saloni likes this
0 votes
rbalamu2
Contributor
July 18, 2022

Hi  ,
I want to restrict Epic creation based on project role.
I want only "Administrator" of that project should be able to create Epic. Is that possible?
For all the project I want to add this validator. Kindly help!

I am using JMWE plugin -> Build your own validator.

Eric Sebian
Contributor
January 23, 2023

will this work with the server version of JMWE?

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2023

@Eric Sebian ,

Not this code, no, as it is written in Jira Expressions, which is Jira Cloud-specific. On Server/DC, you need to use Groovy:

issue.get("issuetype").name != "Epic" || currentUser.isInProjectRole("Administrator", issue.get("project"))
Eric Sebian
Contributor
January 24, 2023

thanks David. Would I create that under Shared Groovy Script Editor? I dont see any other place that this would work.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2023

Hi @Eric Sebian ,

this is meant to be used in a Scripted (Groovy) Validator.

Eric Sebian
Contributor
January 25, 2023

Ahh. So, it won't block a requester from selecting a specific issue type. Just restricts them from completing the request. Good to know. Thanks. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events