Hi everyone,
i wrote a script for a custom field to show or hide it based on another custom field value. The script works perfectly fine, when i create an issue and the field configuration for the issue is directly the one the fields are used in.
If the create screen starts with a different issue type or project (so of course a different field configuration) and i change to the right project and issue type, the script does not work.
I put the script in all field configurations to the custom field, so I don't know why Jira does not uses it.
The script I put in the description of the custom field (in every field configuration) is this:
<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
callChangeFunction();
});
function callChangeFunction() {
//showHidField();
// dropdown custom field change function
$("#customfield_10027").change(function() {
showHidField();
});
}
function showHidField() {
//drop down field selected value
var dropDownFieldval =$("#customfield_10027").val();
//test field1
$("#customfield_10404").hide();
$('label').each(function(index){
if($(this).attr('for') == 'customfield_10404'){
$(this).hide();
}
});
if(dropDownFieldval != '10063' && dropDownFieldval != ''){
$('label').each(function(index){
if($(this).attr('for') == 'customfield_10404'){
$(this).show();
}
});
$("#customfield_10404").show();
$("#customfield_10404").css("border", "2px solid red");
}
}
callChangeFunction();
});
</script>