Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Clear the Assigned to field when the Assignment Group changes

vigo
Kilo Explorer

I am trying to using a onChange Client Script to clear the value of the Assigned To field when the Assignment Group changes. I tried to use the one that was posted on the messages, but it is not working.

Here is what I have:

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

if (isLoading) {  

return;  

}  

 

if (newValue == ''){

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

 

}      

}

This is not working, any suggestions?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Vinay,



Below script will blank out the assigned_to field when the assignment group changes.


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


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


  return;


  }


  var assGrp = g_form.getControl('assignment_group');


  if(assGrp.changed)


  {


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


  }


  //Type appropriate comment here, and begin script below



}


View solution in original post

22 REPLIES 22

Uncle Rob
Kilo Patron

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Vinay,



Below script will blank out the assigned_to field when the assignment group changes.


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


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


  return;


  }


  var assGrp = g_form.getControl('assignment_group');


  if(assGrp.changed)


  {


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


  }


  //Type appropriate comment here, and begin script below



}


Thanks, Pradeep I tried in my dev instance and it is not working. I also changed g_form.setValue('assigned_to',''); to g_form.clearValue('assigned_to',''); and it still does not clear the Assigned To field.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Can you point me to the instance where it is not working.