How to show/hide a JIRA field based on other field's value

Submitted by ravisagar on Tue, 10/07/2014 - 21:04

JIRA is indeed one of the best issue tracker in the market. The best thing about this tool which I like is the customizations that you can do in it that too managed from the UI itself. Of course there are lot of things are can be done through the interface but sometimes there could be a possibility that you are looking to implement some behavior in the the interface but couldn't find the right solution.

Today we will discuss one such scenario. For instance you want users to fill up a custom field called "Analysis" only when they select priority as critical. Now to implement this show/hide behavior there is no such configuration you can do. There is one custom field type for creating Cascading Select list in JIRA but that is just to show different values in the child select list based on parent. It is relevant in cases like where you want to capture Country/City but that won't solve our purpose.

The scenario we are looking for can be implemented using a javascript, which is obvious choice for implementing such cases but the question is where should we write is js code? There are various ways of doing it. First you can create a web resource and add it as a plugin in your JIRA instance which is the preferred way but if you are not comfortable then you can also add this code in the description field of your custom field.

The description field supports HTML and Javascript both and the code below will be added in the page when you try to create the issue in JIRA.

Points to remember
1. Modify the ID of the custom field that you want to show/hide in this code. For instance in the above code the ID is 10000, you can find the ID of the custom field when you click on the Configure option for that particular custom field. The ID can then be found in the url.
2. In the above example we are showing the custom field when Priority is equal to Critical, whose value is 2, if you want to do this for some other value, you should also change the number and of course this can be done for any other custom field too. Just modify the code accordingly.