Hello Team,
I have an AJAX code with me, which I would like to place near the description of a custom field and make sure auto populating of field values onto the create screen happens, but it does not work. Here is my code.
<script type="text/javascript">
(function($) {
function prepopulateTeam(){
//$(document.getElementById("issuetype-field")).change(function(){
$(document.getElementById("customfield_14041")).change(function(){
issueType = document.getElementById("issuetype-field").value;
//system=document.getElementById("customfield_14041").value;
//currentUser=document.getElementById("")
//if(issueType=="Program Risk" || issueType=="Part Risk" || issueType=="Manufacturing Risk" || issueType=="Quality Risk"||issueType=="Test and Validation Risk"){
switch (issueType) {
case "Program Risk": //if the issue type is Product Engineering
AJS.$(document.getElementById("customfield_16029")).val("sushma.nagaraj");
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj");
//AJS.$(document.getElementById("customfield_15208")).val("peter.savangian"); //set Champion field
break; //end case
// case "BODY": //if the issue type is Test and Validation
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// case "INTERIOR": //if the issue type is Supply Chain
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// // THER IS NO defined sub-program lead for quality, so default to xiao
// case "THERMAL": //if the issue type is Quality
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// case "ENERGY STORAGE AND CHARGING": //if the issue type is Homologation
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// case "CHASSIS": //if the issue type is Finance
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// // THER IS NO defined sub-program lead for Resrouces, so default to xiao
// case "POWERTRAIN": //if the issue type is Resources
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break; //end case
// case "ELECTRICS AND ELECTRONICS": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "USER INTERFACE": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "SOFTWARE": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "EXTERIORS": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "STANDARD PART": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "MISCELLANEOUS": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
// case "MASTER SURFACE": //if the issue type is Manufacturing and Facility
// AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
// //AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
// break;
//end case
}
} //end switch
}); //end change event
} //end prepopulateTeam()
AJS.toInit(function(){ //init function
prepopulateTeam();
}); //end init
}
AJS.$(document).ready(function() {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
function explode(){
function prepopulateTeam(){
/*
Set some of the "Team" fields based on the issueType
The Intiator field is set based on a post funtion script
The Assignee field is set based on a post funtion script
*/
$(document.getElementById("customfield_14041")).change(function(){
issueType = document.getElementById("issuetype-field").value;
system=document.getElementById("customfield_14041").value;
//currentUser=document.getElementById("")
if(issueType=="Program Risk" || issueType=="Part Risk" || issueType=="Manufacturing Risk" || issueType=="Quality Risk"||issueType=="Test and Validation Risk"){
switch (system) {
case "OTHER":
//if the issue type is Product Engineering
AJS.$(document.getElementById("customfield_16029")).val("sushma.nagaraj");
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj");
//AJS.$(document.getElementById("customfield_15208")).val("peter.savangian"); //set Champion field
break; //end case
case "BODY": //if the issue type is Test and Validation
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
case "INTERIOR": //if the issue type is Supply Chain
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
// THER IS NO defined sub-program lead for quality, so default to xiao
case "THERMAL": //if the issue type is Quality
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
case "ENERGY STORAGE AND CHARGING": //if the issue type is Homologation
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
case "CHASSIS": //if the issue type is Finance
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
// THER IS NO defined sub-program lead for Resrouces, so default to xiao
case "POWERTRAIN": //if the issue type is Resources
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break; //end case
case "ELECTRICS AND ELECTRONICS": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "USER INTERFACE": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "SOFTWARE": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "EXTERIORS": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "STANDARD PART": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "MISCELLANEOUS": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
case "MASTER SURFACE": //if the issue type is Manufacturing and Facility
AJS.$(document.getElementById("assignee-field")).val("sushma.nagaraj"); //set Assignee
//AJS.$(document.getElementById("customfield_17536")).val("sushma.nagaraj"); //set Champion field
break;
//end case
}
} //end switch
}); //end change event
} //end prepopulateTeam()
prepopulateTeam();
} //end explode
}); //end JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason)
AJS.$(document).bind('dialogContentReady', function(event, dialog) {
setTimeout(explode, 50);
}); //end AJS.$(document).bind('dialogContentReady', function(event, dialog)
}); //end AJS.$(document).ready(function
})(AJS.$); //end (function($)
</script>