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,

Christian

5 answers

This widget could not be displayed.

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

This widget could not be displayed.

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?

https://jamieechlin.atlassian.net/wiki/display/JBHV/Miscellaneous+Behaviours+Examples

This widget could not be displayed.
Mizan Community Champion Feb 19, 2013

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]

This widget could not be displayed.

Jamie

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 197.1.18.83 /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

This widget could not be displayed.

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) {

componentIds.add(componentFormValue)

}

}

Map fieldOptions = [:]

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

for (Long componentId : componentIds) {

try {

Long.parseLong(componentId)

} catch (NumberFormatException e) {

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

return

}

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

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

case "Network Issue" :

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

break

}

}

formSubcomponent.setFieldOptions (fieldOptions)

}

Appreciate your help.

Regards,

MG

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

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