Custom web item only for specific role in a specific project

Antonio D'Errico November 3, 2017

I want that only a specific role in a specific project can see the link in the top-navigation.bar in jira. how should the condition look like?

this link is for the service-desk-agents in a service desk project. they can quickly open the queues with that. if i leave the condition blank every user can see this link. but i want only this menu-point. only the agents in this service-desk-project should see the link.

2017-11-03_151703.png2017-11-03_151826.png

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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.
November 3, 2017

Hello,

The codition would look somthing like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.security.roles.ProjectRole

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager)
def project = ComponentAccessor.getProjectManager().getProjectByCurrentKey("ProjectKey")
ProjectRole administratorProjectRole = projectRoleManager.getProjectRole("RoleName");
if (projectRoleManager.isUserInProjectRole(user, administratorProjectRole, project)) {
return true
} else {
return false
}
Antonio D'Errico November 3, 2017

nice thx a lot!

Suggest an answer

Log in or Sign up to answer