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 project
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
Collection<IssueType> allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects
ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
FormField issueTypeField = getFieldById(ISSUE_TYPE)
ArrayList availableIssueTypes = []
//Check Role
ArrayList<String> remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
if ('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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.