Multi checkbox options aren't selected if there is a script on the field

Hello,

I am trying the behaviours plugin (0.5.3) in Jira 5.2.4.1 and noticed that it doesn't work really good with multi checkbox.
I created a custom field as multi checkbox and added a new behavior on it. If one option is selected a select field is displayed.
I used a small groovy script for it:

FormField cField = getFieldById("customfield_10397");
FormField sField = getFieldById("customfield_10396");

cField.setHelpText(cField.getFormValue())

if (cField.getFormValue() == "10226") {
 sField.setHidden(false);
} else {
 sValue = sField.getFormValue();
 sField.setFormValue("-1");
 sField.setHidden(true);
}

This works good so far. But if I want to edit the issue the selected options aren't selected.

Is it a bug or do I use the API in a wrong way?

1 answer

i don't have knowlde on behaviour plugin,

but you can doit by using javascript, if you want you can try with this code by adding in field description of select list in field configuration

<script type="text/javascript">  
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		callFunction();
	});
		callFunction();
function callFunction(){
		showorhidefields();
	//assume you have two check boxes 
	$("#customfield_10397-1,#customfield_10397-2).click(function() {
			showorhidefields(); 
		});
}

function showorhidefields(){
var checkedCheckboxes = $("input:checkbox[name=customfield_10397]:checked");
		//select field
		$("#customfield_10396").closest('div.field-group').show();
checkedCheckboxes.each(function () {
	var selVal=$(this).val(); 
		if(selVal != '10226'){//id of Yes check box	
			$("#customfield_10396").val('');
			$("#customfield_10396").closest('div.field-group').hide();
		}
});

}
});
</script>

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

127 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you