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)
Based on what condition do you intend to hide the issue type?
Is it on the current logged-in user's role or group?
If it is based on the User's Role, you can follow the steps provided in this ScriptRunner Documentation, which is the same approach you are using in the code you have shared.
On the other hand, if it is based on the User's group, you can follow the example that I provided in this community discussion.
I hope this helps to answer your question. :)
Looking forward to your feedback.
Thank you and Kind regards,
Ram
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.