JIRA Adaptivist Behaviors to turn off edit pencil

Rich Wolverton October 17, 2018

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.

2 answers

1 accepted

0 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 17, 2018

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.

Rich Wolverton October 17, 2018

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. 

Rich Wolverton October 17, 2018

Adding the two screen shots, one for an Admin user and normal userAdmin User.jpgNon-Admin.jpg

0 votes
Sabine Van Regenmortel August 12, 2022

@Rich Wolverton 

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);
}

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events