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")) {
priorityField.setHidden(true)
} else {
priorityField.setHidden(false) 
}
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
import com.atlassian.jira.security.roles.ProjectRoleManager
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())) 
   { 
    hideableCF.setHidden(false)
   } 
else { // or if not, lock it
      hideableCF.setHidden(true)
     }
					
				
			
			
			
				
			
			
			
			
			
			
		You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
 
 
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.