Created
April 27, 2021 05:48
-
-
Save vikrantyadav11/82ebc5f885bb3dc8cdeeabe54933779d to your computer and use it in GitHub Desktop.
Hide old issue types which are not in use using Script Runner Behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.security.roles.ProjectRoleManager | |
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE | |
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager) | |
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects | |
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser | |
def issueTypeField = getFieldById(ISSUE_TYPE) | |
def projectManager = ComponentAccessor.projectManager | |
def availableIssueTypes = [] | |
def allProjects = projectManager.getProjects() | |
def projectRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name | |
if(projectRoles==["Administrators"] || projectRoles== ["Users"] || projectRoles== ["Developers"] || projectRoles==["Business Analysts"] || projectRoles==["Deployment"]) | |
{ | |
availableIssueTypes.addAll(allIssueTypes.findAll { (it.name != "Flexpay Easy") }) | |
} | |
else | |
{ | |
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Client Plan", "Deployment", "Development/Improvement", "Support", "User Setup","Client Renewal"] }) | |
} | |
issueTypeField.setFieldOptions(availableIssueTypes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment