We have a lot of components and they are in different forms. We have a kind of issue type for example Story, I need it can only choose some of the components, not all of them. Is that possible? For example, project components are 1,2,3,4,5 and Story can only choose 1 and 2.
Heya @Jason Liu
So one method that I'm aware of is utilising this script runner code here:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
def projectRoleManager = ComponentAccessor.getComponent ProjectRoleManager.class
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def targetRoleName = 'Special Users'
def project = getIssueContext().projectObject
def projectComponents = project.components
def currentUserRoleNames = projectRoleManager.getProjectRoles(currentUser, project)*.name
if (!currentUserRoleNames.contains(targetRoleName)) {
getFieldById(COMPONENTS).setFieldOptions(
projectComponents.findAll {
it.name in [
'02-HELPDESK',
'03-SECURITY'
]
}.collectEntries {
[
it.id.toString(),
it.name
]
}
)
}
If you don't have script runner let me know and I'll think of another solution for you! :)
Kind Regards,
Ashley Hudson
is there any other method to do it without script runner?
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.