Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Java script for assignee field

Sushma Nagaraj September 27, 2018 edited

Hello team,

 

I have a java script that prefills value for certain fields on the create screen. It shows a value for assignee  on the create pop up window. But when I press the create button and the issue is created the assignee remains unassigned and I am really not sure why it happens to the assignee field alone while it works for other fields.

Here is the code I am using:

<script type="text/javascript">
(function($) {

AJS.toInit(function(){

function buildTheTeam(){

AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

break;
default:
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

}


});


}
function buildTheTeam1(){

var issuetype=AJS.$("#issuetype-field").val();
AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

break;
default:
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

}


});


}

buildTheTeam();


});


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

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {

var issuetype1=AJS.$("#issuetype-field").val()

if(issuetype1=="Manufacturing Risk"){

AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

break;
default:
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

}


});


}
else if(issuetype1=="Part Risk"){
AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("ray.pang");
//consulted
AJS.$("#customfield_17538").val("ray.pang");

break;
default:
AJS.$("#assignee-field").val("ray.pang");
//consulted
AJS.$("#customfield_17538").val("ray.pang");

}


});


}
AJS.$(document).bind('dialogContentReady', function(event, dialog) {

var issuetype1=AJS.$("#issuetype-field").val()

if(issuetype1=="Manufacturing Risk"){

AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

break;
default:
AJS.$("#assignee-field").val("romeo.andaya");
//consulted
AJS.$("#customfield_17538").val("mark.dymek");

}


});


}
else if(issuetype1=="Part Risk"){
AJS.$("#customfield_15533").closest('div.field-group').hide();
$(document.getElementById("customfield_14041")).change(function(){

switch ($(document.getElementById("customfield_14041")).val()) {
case "23125":
//assignee
AJS.$("#assignee-field").val("ray.pang");
//consulted
AJS.$("#customfield_17538").val("ray.pang");

break;
default:
AJS.$("#assignee-field").val("ray.pang");
//consulted
AJS.$("#customfield_17538").val("ray.pang");

}


});

}



});


});


});

})(AJS.$);
</script>

1 answer

0 votes
Ahmed_Bilal July 29, 2020

I am having same issue any luck?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events