Hi Team,
We have a requirement to remove three specific issue types—"Epic," "Enabler," and "Feature"—from hundreds of Jira projects. However, we want to keep the existing tickets under these issue types for all projects. Since these 100+ Jira projects have various other issue types, I cannot simply include them all in the user roles. Therefore, I want to exclude these three issue types. I tried using the following ScriptRunner behavior, but it still shows all the issue types available in the project instead of excluding these three. Is there something wrong with my script?
I am in a "User" role, but its displaying "Epic," "Enabler," and "Feature"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def constantsManager = ComponentAccessor.constantsManager
def allIssueTypes = constantsManager.allIssueTypeObjects
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)
def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []
if ("Issue Type Visibility Controller" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Epic", "Enabler", "Feature"] })
}
if ("Users" in remoteUsersRoles) {
def excludedTypes = ["Epic", "Enabler", "Feature"]
availableIssueTypes.addAll(allIssueTypes.findAll { !(it.name in excludedTypes) })
}
issueTypeField.setFieldOptions(availableIssueTypes)
Hi @jira_admin_cu ,
I suggest to go through this thread: https://community.atlassian.com/forums/App-Central-questions/Hide-Issue-Types-with-ScriptRunner-Behaviors-not-working/qaq-p/2916028
I hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.