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

venkatrajesh
Tera Expert

Hi All



correct function is clearValue instaed of setValue


find_real_file.png


PS: Hit like, Helpful or Correct depending on the impact of the response


HI found that this script didn't function on an Incident record when it was built for the Task table.   Same script on the Incident table worked perfectly.



~Paul


Hi, I know this a a old question, but I have the same problem, may I know if there a solution to make it works on other table such as 'case'? Thank you