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

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

This widget could not be displayed.

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.

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.

This widget could not be displayed.

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;

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

This widget could not be displayed.

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?

This widget could not be displayed.

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.

Is there a good reference document to learn these things?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

83 views 1 0
Join discussion

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