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.
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.