Restrict Priority to only Administrators

We are trying to set a Behavior to restrict the priority to only

Team Members

 role.  Not sure what we are missing to get it to work.




import com.atlassian.jira.issue.priority.Priority
import com.atlassian.jira.issue.MutableIssue

def priorityField = getFieldById("priority")

if ( isUserMemberOfRole("Administrators")) {
} else {




2 answers

Any thoughts?

Hi - I don't think that that's actually possible. 'Priority' is a built in JIRA field and cannot be truly hidden. Only custom fields of an actual 'hideable' type will behave as you are expecting via behaviors. You could maybe remove Priority from the View and Edit screens, and only show it on a workflow transition screen, where the transition had a validator to check the users group or project role when trying to execute the transition...

Open to correction by someone from he SR team of course, but you might need to try a different approach..

Not that it matters much, but your code needs a few tweaks. This is something I use to hide a custom field and it works for me

import com.atlassian.jira.component.ComponentAccessor
def hideableCF = getFieldById("customfield_12345")
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def devProjectRole = projectRoleManager.getProjectRole("Team Members")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//check if user is in correct role and unlock field
if (projectRoleManager.isUserInProjectRole(currentUser, devProjectRole, underlyingIssue.getProjectObject())) 
else { // or if not, lock it

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,873 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot