Hello,
How can a Scriptrunner Fragment make it apply to multiple project roles?
I'm now using
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.action.ProjectActionSupport
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.roles.ProjectRoleManager
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ProjectActionSupport projectSupport = new ProjectActionSupport();
Project currentProject = ComponentAccessor.getProjectManager().getProjectObj(projectSupport.getSelectedProjectId());
def projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager)
def role = projectRoleManager.getProjectRole("Administrators")
return ( projectRoleManager.isUserInProjectRole(currentUser, role, currentProject) || jiraHelper.project?.key != "SH3")
but want script to also apply to Scrum Masters and Approvers project roles and not only to Administrators.
So what should I include instead of
def role = projectRoleManager.getProjectRole("Administrators")
Thank you very much for your response.
Greetings Marco
You can try something like this:
def projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager)
def allowedRoles = ['Administrators', 'Scrum Masters']
def isUserInAllowedRoles = allowedRoles.any{ projectRole ->
def role = projectRoleManager.getProjectRole(projectRole)
projectRoleManager.isUserInProjectRole(currentUser, role, currentProject)
}
return ( isUserInAllowedRoles || jiraHelper.project?.key != "SH3")
Hi @Peter-Dave Sheehan ,
Thank you, this script works in my scriptrunner fragment.
Regards, Marco
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.