Custom web item only for specific role in a specific project Edited

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 vote
Alexey Matveev Community Champion Nov 03, 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
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

378 views 4 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you