Client Script for Assignment Group Change

Maurie
Kilo Expert

I have been working on this for a while and need some help.

 

We are wanting the State field to change to Active (2) when the Assignment Group changes to anything.   Also, The Assigned to should blank out when the Assignment Group changes (I havent started coding this part yet).

 

i have gotten to the point that the system will notify me that the field changed, but will not update the other fields.

 

Here is my code so far:

 

function onSubmit() {

  var field1 = g_form.getControl('assignment_group'); //Get the 'Assignment Group' field control

 

  //See if the 'changed' attribute on either field is true

  if(field1.changed) {

      return confirm("Assignment Group on the form have changed.\nDo you really want to save this record?");

        if (stateValue != '2'set stateValue =='2';

  }

 

}

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Maurie



Here you go..


Script:On change client script


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue == '') {


          return;


    }


if(newValue != oldValue)


{


var answer = confirm("The Assigned Group on the form have changed.\nDo you really want to save this record?");


  if (answer == true) {


g_form.setValue('state',2);


g_form.setValue('assigned_to','');


return true;


}


else


{


return false;


}


}



Please let me know if you have any further questions



Good luck!



Thanks


Pradeep Sharma


Service now certified implementation specialist


Cognizant


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Maurie



Here you go..


Script:On change client script


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue == '') {


          return;


    }


if(newValue != oldValue)


{


var answer = confirm("The Assigned Group on the form have changed.\nDo you really want to save this record?");


  if (answer == true) {


g_form.setValue('state',2);


g_form.setValue('assigned_to','');


return true;


}


else


{


return false;


}


}



Please let me know if you have any further questions



Good luck!



Thanks


Pradeep Sharma


Service now certified implementation specialist


Cognizant


thank you so much for your help.   This fixed my problem.


I am glad I can be helpful to you


Would you mind marking my answer as correct.



Thanks,


Pradeep Sharma


Hi pradeep,



i too have same question..when i am changing the assignment group on incident from state is zero.why?