Copy this code in the description of a custom field (in the Field Configuration linked to the project)

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
    callChangeFunction();
});
    callChangeFunction();
function callChangeFunction(){
        showHidField();
    // dropdown custom field change function
    $("#customfield_10625").change(function() {
        showHidField();
    });
        showHidSubTaskField();
    $("#customfield_10640").change(function() {
        showHidSubTaskField();
    });
 
}
 
function showHidField(){
    //drop down field selected value
    var dropDownFieldval =$.trim($("#customfield_10625 :selected").text());
    //test field1
        $("#customfield_10639").closest('div.field-group').hide();
    if(dropDownFieldval == 'Project'){
        $("#customfield_10639").closest('div.field-group').show();
    }if(dropDownFieldval == 'Release'){
        $("#customfield_10639").closest('div.field-group').show();
    }
}
function showHidSubTaskField(){
 
    //drop down field selected value
    var dropDownFieldval =$.trim($("#customfield_10640 :selected").text());
    //test field1
        $("#customfield_10645").closest('div.field-group').hide();
    if(dropDownFieldval == 'Project Audit'){
        $("#customfield_10645").closest('div.field-group').show();
    }if(dropDownFieldval == 'Release Audit'){
        $("#customfield_10645").closest('div.field-group').show();
    }
 
}
 
});
 
</script>

Advertisements
Posted by:.

2 replies on “How to Show/Hide Custom Field depend on another custom Field Value in JIRA

    1. You can set Javascript in the description of a field, placed on a screen (only in Jira Server)

      Examples:

      IF WE CREATE THE ISSUE IN FULLSCREEN
      i_type = AJS.$("#issue-create-issue-type").text();
      if ( document.getElementById("description").value == "" && (i_type == "Epic" || i_type == "Story"||i_type == "Technical Story" ))  {
      ....
      }
      
      
      OR IF WE CREATE THE ISSUE IN POPUP
      if (AJS.$("#issuetype-field")) {
      i_type2 = AJS.$("#issuetype-field").val();
      ...
      }
      
      

      Regards

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s