Populate a field based on another field's content in Jira server

Still need help?

The Atlassian Community is here for you.

Ask the community

Please note that adding Javascript to custom fields is a customisation and not maintained as a supported part of JIRA.

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

NOTE:

in Jira 8.7 and later a setting was added with the default shifted to OFF as covered in:

To use the following article make sure to set the global setting to enabled as covered in the following documentation to use scripts in the field descriptions

Enable HTML in custom field descriptions and list item values:

Allows to add HTML to the descriptions of custom fields and the values of list items.

Default: OFF (recommended for security)  


Purpose

JIRA currently has no way to display a field based on another field's selection. This article provides a workaround using javascript to accomplish this goal. For more information please refer to the linked JAC ticket:

JRA-41352 - Getting issue details... STATUS

Solution

If you would like show a Field B, ONLY if certain value from Field A is chosen, it can be achieved by performing the following steps:

  1. Create a "Free Text Field (unlimited text)" custom field type in the (Administration -> Issue Fields -> Custom Fields) page
  2. In this example, if a Priority - Critical (Field A) has been chosen for an issue, another field (Field B) will be displayed. Fill in the following text into the Description field (Field B):

    <script type="text/javascript">
      priority = document.getElementById('priority');
      if (priority) {
          target = document.getElementById('customfield_10000');
          // Hide the target field if priority isn't critical
          if (priority.value != 2) target.style.display='none';
     
          priority.onchange=function() {
              if (this.value == 2) {              
                         target.style.display = '';  
                         target.value="enter message here";
                      } else {
                     target.style.display='none';
              }
          }
      }
     </script>
    

    Make sure to change the customfield_ID and priority.value. To find the customfield_id, view the source of the page when viewing an issue, or check the URL when editing a custom field.

DescriptionJIRA currently has no way to display a field based on another field's selection. This article provides a workaround using javascript to accomplish this goal.
ProductJira
PlatformServer
Last modified on Apr 27, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.