Hello Team,
I have a Java script which works pretty well except for the case when a issue create pop up screen appears. It works for this case too but after I have opened the pop up screen two times, it starts pre populating the field value the third time I open the create pop up window, any idea as to how I could make changes to the code so that it works the very time I open the create pop up window.
<script type="text/javascript">
(function($) {
// This is for when an issue is being created while
// opened in a new window tab
AJS.toInit(function(){
if (AJS.$("#issue-create-submit").val()=="Create" // || AJS.$("#create-issue-submit").val()=="Create"
){
var issuetype=AJS.$("#issue-create-issue-type").text();
if(issuetype=="Task"){
$(document.getElementById("customfield_14041")).change(function(){
switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
AJS.$("#assignee-field").val("Sushma.nagaraj");
break;
default:
AJS.$("#assignee-field").val("Sushma.nagaraj");
}
});
}
}
});// This is when issue is being created via dialog box popup.
//AJS.$(document).ready(function() {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
if (
// AJS.$("#issue-create-submit").val()=="Create" ||
AJS.$("#create-issue-submit").val()=="Create"){
var issuetype=AJS.$("#issuetype-field").val();
if(issuetype=="Task"){
$(document.getElementById("customfield_14041")).change(function(){
switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
AJS.$("#assignee-field").val("Sushma.nagaraj");
break;
default:
AJS.$("#assignee-field").val("Sushma.nagaraj");
} });}
}
});})(AJS.$);
</script>