JQuery script to clear field worked in JIRA 4 but does not in 6

Edward Sargent August 14, 2013

The script empties Assignee if another field changes, in this case the custom field Location

<script type="text/javascript">

jQuery(document).ready(function() {

var location_fld = document.getElementById("customfield_10505");

var assignee_fld = document.getElementById("assignee");

location_fld.onchange = function(){

assignee_fld.value = "";

}

});

</script>

I am a novice at modifing JIRA with scripts so please don't provide me a geeky response that I can't follow. This is a new copy of JIRA on a new server, not an upgrade, so maybe a missing plugin or configuration is at fault.

4 answers

0 votes
Edward Sargent August 16, 2013

The code was breaking the maintenance page for Custom Fields so I removed it. I will need to readdress this later when I have the time. Thanks for your help.

Edward Sargent August 16, 2013

Is there a good reference document to learn these things?

0 votes
Edward Sargent August 15, 2013

I had seen the JIRA.bind... on responses to other questions but did not know what it was for. Anyway I applied it but the problem remains. Do these scripts still go in the description field?

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

your code also seems correct but you have to include that in following event

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
//your logic here
});

you can try with following code

&lt;script type="text/javascript"&gt;  
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		clearAssignee();
	});
		clearAssignee();
function clearAssignee(){
	$('#customfield_10505').change(function() {	
		$('#assignee').val('');
	}):
		
	}

});
&lt;/script&gt;

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2013

the bind event is used here to execute the JavaScript on popup's(ex. create issue, transition, edit issue popup's ).

yes, it should be added in description of custom field in field configuration

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

If you are modifying JIRA templates to insert your own scripts, you may need to encounter "geeky" answers...

Instead of using jquery, use AJS, atlassian's wrapper.

AJS.$(document).ready(function() {

Second, use the page source view (ctrl+U in chrome) to verify that the IDs are both still valid.

Edward Sargent August 14, 2013

I'm afraid I'm on a timelime and JIRA is not my normal responsibility. I don't have the time to learn AJS, when I finish this project I will probably not use JIRA for some time as my job is Unix/Linux support.

Suggest an answer

Log in or Sign up to answer