We are testing a Behavior to only allow Project Admins to update Priority.
We did the documented steps to make Priority readonly except for people in the Role Administrators. This works but leaves the edit Pencil on the field. When a non-Admin user clicks on the pencil they get the Edit screen with the Priority grayed out. I have tried the following in the Initialiser but does not seem to have an effect:
getFieldById("Priority").setReadOnly(true)
Any suggestions or additional steps would be much appreciated.
Hello @Rich Wolverton
Scriptrunner behaviours doesn't work on view screen. Clicking the pencil will always open edit screen, so your main goal is achieved.
But if you stiil want to remove the edit pencil, the only possible way is to write some JavaScript code and place it in the announcement banner for example, but this method strongly not recommended.
Thanks @Mark Markov but disappointed.
When allowed to update Priority there is a drop down that shows Priority values. It is only for the large community that is not allowed to update that they get the 'edit' screen. Just seems more intuitive that readonly would suppress the edit Pencil.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding the two screen shots, one for an Admin user and normal user
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is my initializer code. There might be redundancies in the imports and defs but this should work.
Edit pencil is not turned off but Priority is only editable to Administrators in Edit Screen.
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.project.version.VersionManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def prio = getFieldById("priority")
def isAdmin = "Administrators" in remoteUsersRoles
Long projectId = issueContext.projectObject.id
prio.setHidden(true);
if ( isAdmin ){
prio.setHidden(false);
} else {
prio.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.