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 Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,752 views 18 21
Read article

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