Hide components based on issue type

Hi all,

I was wondering if anyone has ever had to hide components based on issue type. I know that this question is most likely a duplicate of https://answers.atlassian.com/questions/128050/how-to-create-components-based-on-issue-type

but I wanted to know if I can hide specific components via Javascript or the behaviours plugin...

Anyone has ever done sth. like this?

Thanks for any hints,


5 answers

I think you can... you can remove components from the available selection so you should be able to do that based on issue type.

How would I remove them...Maybe you could point me to the right direction. Would that be close to what youre describing in your example

Add or remove options to single or multi-select fields

on your example page?


Based on issuetype you can set options to the component field , refer this similar example for setFieldOptions() . The map for component field options will contain [id:name]


I am using above code to set Custom field - Applications based on Component in JIRA 6.0.2

I am getting below errors: can you pls guide me what could be issue here?

,807 http-bio-9000-exec-19 ERROR 570x161444x1 l5xrx1 /secure/QuickCreateIssue.jspa [groovy.canned.utils.ConditionUtils] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script28.groovy: 2: unable to resolve class FormField
@ line 2, column 15.
FormField formComponent = getFieldById(fieldChanged)

Script28.groovy: 3: unable to resolve class FormField
@ line 3, column 15.
FormField formApplications = getFieldByName ("Applications")

Script28.groovy: 29: unable to resolve class GenericValue
@ line 29, column 22.
GenericValue component = componentManager.getProjectManager().getComponent(Long.parseLong(componentId))

3 errors

Hi Raj,

I presumed you have missed out the imports:

import org.ofbiz.core.entity.GenericValue

import com.atlassian.core.ofbiz.util.OFBizPropertyUtils

Hi guys,

For my case, the subcomponent field does not reflect. Here is my code:

import org.ofbiz.core.entity.GenericValue

import com.atlassian.core.ofbiz.util.OFBizPropertyUtils

public void setSubComponentOptions () {

FormField formComponent = getFieldById(fieldChanged)

FormField formSubcomponent = getFieldById("customfield_10901")

Object componentFormValue = formComponent.getFormValue()

List componentIds = []

if (componentFormValue instanceof List) {

componentIds.addAll(componentFormValue as List)


else {

// could be an empty string if all components are deselected

if (componentFormValue) {




Map fieldOptions = [:]

fieldOptions.put ("-1", "None")

for (Long componentId : componentIds) {

try {


} catch (NumberFormatException e) {

log.error ("Could not get component Id as Long")



GenericValue component = componentManager.getProjectManager().getComponent(Long.parseLong(componentId))

switch (component?.get("name")) {

case "Network Issue" :

fieldOptions.putAll (["11201":"SAP"])




formSubcomponent.setFieldOptions (fieldOptions)


Appreciate your help.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,172 views 5 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you