You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi community,
I am using the "Hide system or plugin UI element" from ScriptRunner Add-On to hide a Link in the UI and it works to hide it for all members of the project.
Is it possible to change the condition so that the link is only hidden for the members of some project roles? I have not found any way to access the roles or the current user yet.
Thanks
Bastian
It would be like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def project = jiraHelper.project?.key
String roleName = "Administrators"
if (project != null) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager);
def projectRole = projectRoleManager.getProjectRole(roleName)
return projectRoleManager.isUserInProjectRole(user, projectRole, issue.getProjectObject())
}
return false
Hi @Alexey Matveev,
thank you very much for this quick response.
I had to change the line:
return projectRoleManager.isUserInProjectRole(user, projectRole, issue.getProjectObject())
to
return projectRoleManager.isUserInProjectRole(user, projectRole, jiraHelper.project)
because there is not always an issue selected, but now it works great.
Best regards
Bastian
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.
Hi @Alexey Matveev ,
Could you please tell how to modify your suggested code to have some operations visible for two or three different project roles instead of just "Administrators"? Like visible for project roles "Administartors" and "Service Desk Team".
Many thanks! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this solution for more than one role:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.util.UserManager
def project = jiraHelper.project?.key
if (project != null) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager);
def projectRoleAdmin = projectRoleManager.getProjectRole("Administrators")
def projectRoleSDT = projectRoleManager.getProjectRole("Service Desk Team")
Boolean isAdmin = projectRoleManager.isUserInProjectRole(user, projectRoleAdmin, jiraHelper.project);
Boolean isSDT = projectRoleManager.isUserInProjectRole(user, projectRoleSDT, jiraHelper.project);
if(isAdmin || isSDT){
return true;
}
}
return false
Best regards,
Artiom
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.
Hi all,
Could you help me please to hide voters from mentioned project in Jira ?
I have tried to hide voters with same code, but it isn't working.
Maybe I am using not correct module ?
I tried this modules
com.atlassian.jira.plugin.system.issueoprations:vote-issue,
com.atlassian.jira.plugin.system.issueoprations:view-voters,
com.atlassian.jira.plugin.system.issueoprations:unvote-issue
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.