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
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...

145 views 1 17
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