I need to limit the creation of some issuetypes in a project and for users of a specific role.
I used this script but it still gives me an error.
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 remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []
if ("Users" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Bug"] })
}
if ("Developers" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Task"] })
}
issueTypeField.setFieldOptions(availableIssueTypes)
Your script works fine for me (tweaking the user roles and issue types to match my environment). What sort of error are you receiving?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Micaela,
I think Issue_TYPE should be all capitals instead : ISSUE_TYPE. Otherwise just save the script as is, ignore the warnings/errors.
Antoine
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.
You are not supposed to run this script in script console, but instead create a behaviour linked to the "Issue Type" field.
Then it should work fine (because issueContext will exist at execution time).
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, i'll try.
What should I change to be able to run the script only for a specific project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just configure the behaviour so it applies only to the specific project (Add Mapping). :)
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.
You are missing a "," between user and issueContext. Also as I said you need to create a behaviour (GG > Behaviours)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, it works now, but this solution does not work with jira JIRA Software 7.10.0 while it works with version 7.9.0.
Can anything be done?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is beyond my knowledge, you would need to contact someone from adaptavist (raise a support ticket).
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.