There are 10+ Issuetypes in the project ,how to allow only reporters from project role should create only Task Issuetypes in project and all others in the project role should create all other Issuetypes
Hi, @Swati_Mathapati
You can make it with ScriptRunner. If you have it, you can create behavior, and add there following script:
/* * Created 2023. * @author Evgeniy Isaenkov * @github https://github.com/Udjin79/SRUtils */package Examples.Behaviours// Limit issue types, depending from user Role in projectimport com.atlassian.jira.component.ComponentAccessorimport static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPEimport com.atlassian.jira.issue.issuetype.IssueTypeimport com.atlassian.jira.security.roles.ProjectRoleManagerimport com.atlassian.jira.user.ApplicationUserimport com.onresolve.jira.groovy.user.FieldBehavioursimport com.onresolve.jira.groovy.user.FormFieldimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehavioursProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)Collection<IssueType> allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjectsApplicationUser user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()FormField issueTypeField = getFieldById(ISSUE_TYPE)ArrayList availableIssueTypes = []//Check RoleArrayList<String> remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.nameif ('Reporters' in remoteUsersRoles) { availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ['Task', 'Experiment', 'Classified Tasks'] })} else { availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ['Task'] })}issueTypeField.setFieldOptions(availableIssueTypes)
Jira doesn't allow you to restrict creating out of the box. There are some workarounds, but they act after someone tries to create. I suggest searching for 'stopping users from creating issues' as a start. They involve putting validators on the create step in the workflow or using scriptrunner.
There's a neat and simple script in the library for this - see https://library.adaptavist.com/entity/restrict-issue-types?tab=dataCenter
It's always worth checking the library before asking for help with a script - the library scripts are all tested (and updated when needed) by the Scriptrunner team
Thank you all for your responses
It looks like you're new here. Sign in or register to get started.