Make a filed Hide depending on another field using JIRA Behaviours Plugin

Oded Priva May 11, 2014

Hi,

I'm trying to Hide fields on issue create screen if custome field = value,

How can I achive it using a server side script JIRA Behaviours Plugin.

To be more accurate .. I'm looking for examples for a server side scripts that can help me with my task.

4 answers

1 accepted

4 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2014

Hi Oded,

your approach seems correct. I suggest to use beahviour plugin and not a custom javascript.

You could use this example :

FormField fieldFF = getFieldByName("YOUR CUSTOM FIELD NAME HERE");
String fieldValue = fieldFF.getValue();
if("FIELD VALUE".equals(fieldValue)){
   FormField fieldToHideFF = getFieldByName("YOUR FIELD NAME HERE");
   fieldToHideFF.setHidden(true);
}

Hope this helps,

Fabio

Oded Priva May 12, 2014

Thanks,

Can I just return True/False from the serverside script and use the behaviour options?

I have tried the following and it seems to return true all the time ( Report Type field is always in "readonly" state.

Staus field is radio button field type.

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2014

This is a server side script that allows you to add more capability to you custom fields. Whay do you need to return true/false, who should use this value? So if you need to hide the custom field depending to another custom field try to use the provided code.

Regards,

Fabio

Andrian F October 8, 2015

Thanks.. Very Helpful

Seda Atagören November 24, 2020

Thank you for sharing the code, helped a alot ! @Fabio Racobaldo _Herzum_ 

0 votes
BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2014

The behavior you want to implement is typically done with client-side scripting. I agree that adding javascript to the description field is not the most managable option, but you have other solutions:

https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module

You can always create a web resource plugin that injects the java script into JIRA in a clean way. This solution is perfectly manageable, because the plugin can be disabled/removed any time you want.

More examples on javascript and custom fields can be found here:

https://answers.atlassian.com/questions/291978/javascript-to-hide-show-custom-field

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2014

It is btw not best practice to hide/show form fields based on another value, but is is preferable to enable/disable them. In this way it is also obvious for the user which options are available for certain values. This helps him to better understand how the form works and it makes the ui cleaner, without the jumping of ui elements.

0 votes
Oded Priva May 11, 2014

Do you mean updating the "description" of the field with javascript ? if so, I really dont like this method because it is very hard to admin the customisation.

0 votes
BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2014

Hi Oded,

Is there a reason why you prefer server side scription instead of javascript?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events