I am trying to show only few values in the components field using behaviours on the create issue screen. Can anyone help with the Initialiser script ?
This short example limits the list of components in the issue screen to only the components that are less than 5 characters in length:
import com.atlassian.jira.component.ComponentAccessordef allComponents = ComponentAccessor.projectComponentManager.findAllForProject(issueContext.projectId)def componentField = getFieldById('components')def allComponentAsMap = allComponents.collectEntries{["$it.id":it.name]}def smallComponents = allComponentAsMap.findAll{it.value.length() <5}componentField.setFieldOptions( smallComponents)
Thanks @PD Sheehan i was struggling to get the collect entries statement.
This really helps. Appreciate it.
For defining different components
import com.atlassian.jira.component.ComponentAccessor
def allComponents = ComponentAccessor.projectComponentManager.findAllForProject(issueContext.projectId)def componentField = getFieldById('components')
def allComponentAsMap = allComponents.collectEntries{["$it.id":it.name]}def smallComponents = allComponentAsMap.findAll{it.value in ["acomponent", "bcomponent"]}componentField.setFieldOptions( smallComponents)
Thanks @avinashp It helped.
It looks like you're new here. Sign in or register to get started.