Subject: Help Needed – Component and Issue Type Behavior Scripts Not Working Together
Hello Team,
I've implemented two behavior scripts in Jira – one for setting components and the other for restricting issue types – scoped to the ABC project and all issue types.
Script 1: Components Behavior
This script filters and sets allowed components from a predefined list (["a","b","c","d"]) for the Components field.
<span>import com.atlassian.jira.component.ComponentAccessor</span>
<span>def allowedComponentNames = ["a","b","c","d"] </span>
<span>def project = issueContext.projectObject </span>
<span>def projectComponentManager = ComponentAccessor.projectComponentManager def allComponents = projectComponentManager.findAllForProject(project.id) </span>
<span>def allowedComponents = allComponents.findAll { it.name in allowedComponentNames } log.debug("Allowed Components: ${allowedComponents*.name}") </span>
<span>def componentsField = getFieldById("components") componentsField.setFormValue([]) // Clear any pre-selected values componentsField.setFormValue(allowedComponents.collect { it.id.toString() }) </span>
Script 2: Issue Type Behavior
This script limits visible issue types based on user group membership. Users in the Mainframe Technical Support group also see the "Infrastructure" issue type.
groovy
<span>import com.atlassian.jira.component.ComponentAccessor </span>
<span>import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE</span>
<span>def issueTypeField = getFieldById(ISSUE_TYPE) def allowedIssueTypeNames = [ "Break/Fix", "Enhancement", "New Feature", "Question", "Security", "System Performance" ] </span>
<span>def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def groupManager = ComponentAccessor.groupManager</span>
<span>def isMainframeSupport = groupManager.isUserInGroup(user, "Mainframe Technical Support") </span>
<span>if (isMainframeSupport) { allowedIssueTypeNames += "Infrastructure" log.warn(allowedIssueTypeNames) }</span>
<span>def project = issueContext.projectObject def projectIssueTypes = project.issueTypes </span>
<span>d</span><span>ef visibleIssueTypes = projectIssueTypes.findAll { it.name in allowedIssueTypeNames } issueTypeField.setFieldOptions(visibleIssueTypes) </span>
Problem:
Individually, each script works as expected.
Together, only the script placed last (or active) seems to take effect.
I have also tried combining them into a single initializer, but the issue persists.
Request:
Could you help me identify why both behavior scripts aren’t working simultaneously? Is there a known limitation in the Jira Behaviors plugin regarding multiple field-specific scripts or combined logic execution?
Any guidance or workaround would be appreciated.