Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,079
Community Members
 
Community Events
168
Community Groups

JIRA Adaptivist Behaviors to turn off edit pencil

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

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. 

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

@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

Atlassian Community Events