How can I get the value of assignee using AJS.$

Hi All,

Presently I am Using JAVA scripts for getting value of assignee.My objective is to change the assignee based ona field value.

See the present code I am using for that.I wan to convert this using Jquery.

script type="text/javascript">


assignee = document.getElementById('assignee');
source = document.getElementById('customfield_11290');
sourceFieldArea = document.getElementById('customfield_11290').parentNode;
assigneeFieldArea=document.getElementById('assignee').parentNode;
sourceFieldArea.style.display = 'none';
assigneeFieldArea.style.display = 'none';

if (source.value=="value")
{

assignee.value="user1";

}
else
{

assignee.value="user2";
}


</script>

1 answer

This widget could not be displayed.
David Simpson Community Champion Nov 06, 2011

Converting your JavaScript to jQuery, you get something like this:

AJS.toInit(function(){
	$assignee = AJS.$('#assignee');
	$source = AJS.$('#customfield_11290');
	$source.parent().hide();
	$assignee.parent().hide();

	if ($source.val()=='value'){ 
		$assignee.children('option[value="user1"]').attr('selected', 'selected');
} else { $assignee.children('option[value="user2"]').attr('selected', 'selected');
} });

...but there's nothing wrong with pure JavaScript :)

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
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

82 views 0 8
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