Hi ,
We use Jira 4.4.5.
There are few custom fields in our Create Issue page which need to have dependency on other fields.
Most cases it is a 'Text Field' to be displayed only if the Radio button 'Yes' is checked. If Not the Text Field should not be displayed.
There are almost 10 such fileds which have dependency on different Radio button fields.
Say :-
Text Field 1 display depends on Radio button 1
Text Field 2 display depends on Radio button 2
Text Field 3 display depends on Radio button 3
Text Field 4 display depends on Radio button 4
Text Field 5 display depends on Radio button 5
I have used a Java script in one of the Text Field's description to have this effect when the Create Issue page is loaded.
The Java script works fine as intended when i have the code only for 4 fields dependency, when i extend the code to have the logic for all the 10 field depencies then Jira throws an error "Error while accessing Fied Layouts" when i click on 'Update ' button in the Field Edit page, and so the updated code does not get saved.
Note - The whole java script was placed only at one filed's description
#1. I would like to know if there is any limit of Java script code that can be used in the Description of the Custom field.
#2. Is there any other work around to achive the dependencies between the custom fields without using external plugins.
Below is the java script used :
<script language="JavaScript" type="text/javascript">
try {
window.onload=function()
{
document.getElementById('customfield_11306').parentNode.style.display="none";
document.getElementById('customfield_11307').parentNode.style.display="none";
document.getElementById('customfield_11702').parentNode.style.display="none";
document.getElementById('customfield_11902').parentNode.style.display="none";
document.getElementById('customfield_11912').parentNode.style.display="none";
document.getElementById('customfield_11913').parentNode.style.display="none";
document.getElementById('customfield_11917').parentNode.style.display="none";
document.getElementById('customfield_11909').parentNode.style.display="none";
document.getElementById('customfield_11911').parentNode.style.display="none";
if(document.getElementById('customfield_11305-1').checked)
{
document.getElementById('customfield_11306').parentNode.style.display="";
document.getElementById('customfield_11307').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11306').parentNode.style.display="none";
document.getElementById('customfield_11307').parentNode.style.display="none";
}
if(document.getElementById('customfield_11701-1').checked)
{
document.getElementById('customfield_11702').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11702').parentNode.style.display="none";
}
if(document.getElementById('customfield_11900-1').checked)
{
document.getElementById('customfield_11902').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11902').parentNode.style.display="none";
}
if(document.getElementById('customfield_11910-2').checked)
{
document.getElementById('customfield_11911').parentNode.style.display="";
document.getElementById('customfield_11912').parentNode.style.display="";
document.getElementById('customfield_11913').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11911').parentNode.style.display="none";
document.getElementById('customfield_11912').parentNode.style.display="none";
document.getElementById('customfield_11913').parentNode.style.display="none";
}
if(document.getElementById('customfield_11914-1').checked)
{
document.getElementById('customfield_11917').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11917').parentNode.style.display="none";
}
if(document.getElementById('customfield_11908-1').checked)
{
document.getElementById('customfield_11909').parentNode.style.display="";
}
else
{
document.getElementById('customfield_11909').parentNode.style.display="none";
}
Radiochanged();
};
function Radiochanged()
{
document.getElementById("customfield_11305-1").onclick=function()
{
document.getElementById('customfield_11306').parentNode.style.display="";
document.getElementById('customfield_11307').parentNode.style.display="";
document.getElementById('customfield_11306').value="";
document.getElementById('customfield_11307').value="";
}
document.getElementById("customfield_11305-2").onclick=function()
{
document.getElementById('customfield_11306').parentNode.style.display="none";
document.getElementById('customfield_11307').parentNode.style.display="none";
}
document.getElementById('customfield_11701-1').onclick=function()
{
document.getElementById('customfield_11702').parentNode.style.display="";
document.getElementById('customfield_11702').value="";
}
document.getElementById('customfield_11701-2').onclick=function()
{
document.getElementById('customfield_11702').parentNode.style.display="none";
}
document.getElementById('customfield_11900-1').onclick=function()
{
document.getElementById('customfield_11902').parentNode.style.display="";
document.getElementById('customfield_11902').value="";
}
document.getElementById('customfield_11900-2').onclick=function()
{
document.getElementById('customfield_11902').parentNode.style.display="none";
}
document.getElementById('customfield_11914-1').onclick=function()
{
document.getElementById('customfield_11917').parentNode.style.display="";
document.getElementById('customfield_11917').value="";
}
document.getElementById('customfield_11914-2').onclick=function()
{
document.getElementById('customfield_11917').parentNode.style.display="none";
}
document.getElementById('customfield_11908-1').onclick=function()
{
document.getElementById('customfield_11909').parentNode.style.display="";
document.getElementById('customfield_11909').value="";
}
document.getElementById('customfield_11908-2').onclick=function()
{
document.getElementById('customfield_11909').parentNode.style.display="none";
}
}
}
catch (err) {}
</script>