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.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.length() <5}
componentField.setFieldOptions( smallComponents)
Thanks @PD Sheehan i was struggling to get the collect entries statement.
This really helps. Appreciate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @avinashp It helped.
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.