On Jira Server vers 7.2.7
I used this reference to make an embedded help tip, but the result is very long due to the number of components
https://confluence.atlassian.com/jira064/creating-help-for-a-custom-field-720412166.html#
I am interested if possible to only show the div based on the component/s selected, but my code keeps crashing when trying to access the component. My script is in the Component/s description viewable in the configurations
Here is the script I have come up with after modifying what was provided in the example
I thought this would iterate through each component on the issue and only show the divs for the components. (Note I was trying with just the one component to get it working first)
<script type="text/javascript">
import com.atlassian.jira.component.ComponentAccessor;
function showHelp() {
Collection components = issue.getComponents();
Iterator componentIterator = components.iterator();
while (componentIterator.hasNext()){
GenericValue component = (GenericValue)componentIterator.next();
String compName = component.getString("name");
if (compName == 'ComsAlert'){
var listenersDiv = document.getElementById("ComsAlertHelp");
if (listenersDiv.style.display == 'none') {
listenersDiv.style.display = '';
} else {
listenersDiv.style.display='none';
}
}else{
var listenersDiv = document.getElementById("FailedTest");
if (listenersDiv.style.display == 'none') {
listenersDiv.style.display = '';
} else {
listenersDiv.style.display='none';
}
}
}
}
</script>
//divs below