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.
This script filters and sets allowed components from a predefined list (["a","b","c","d"]
) for the Components field.
import com.atlassian.jira.component.ComponentAccessor
def allowedComponentNames = ["a","b","c","d"]
def project = issueContext.projectObject
def projectComponentManager = ComponentAccessor.projectComponentManager def allComponents = projectComponentManager.findAllForProject(project.id)
def allowedComponents = allComponents.findAll { it.name in allowedComponentNames } log.debug("Allowed Components: ${allowedComponents*.name}")
def componentsField = getFieldById("components") componentsField.setFormValue([]) // Clear any pre-selected values componentsField.setFormValue(allowedComponents.collect { it.id.toString() })
This script limits visible issue types based on user group membership. Users in the Mainframe Technical Support
group also see the "Infrastructure" issue type.
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
def issueTypeField = getFieldById(ISSUE_TYPE) def allowedIssueTypeNames = [ "Break/Fix", "Enhancement", "New Feature", "Question", "Security", "System Performance" ]
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def groupManager = ComponentAccessor.groupManager
def isMainframeSupport = groupManager.isUserInGroup(user, "Mainframe Technical Support")
if (isMainframeSupport) { allowedIssueTypeNames += "Infrastructure" log.warn(allowedIssueTypeNames) }
def project = issueContext.projectObject def projectIssueTypes = project.issueTypes
d
ef visibleIssueTypes = projectIssueTypes.findAll { it.name in allowedIssueTypeNames } issueTypeField.setFieldOptions(visibleIssueTypes)
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.
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.
Welcome to the community.
Best is to contact Adapatavist (the vendor and developer or Scriptrunner app).
I do think, you can only have one behaviour per issue type.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.