How to auto populate assignment group based on a custom choices field

Ken61
Giga Guru

I want the assignment group auto populate based on the choices selection. I have a custom choice field and once I select from the choice i want a particular assignment group to auto populate. I need it to populate before I submit the form.

example: My choice field name is "Help" with choices of 'email, alert, Phone'. If I chose email, I want the assignment group to be IT, if I chose phone assignment group should be 'service desk' etc.

I have tried using assignment rule but the assignment group field is mandatory which prevent my assignment rule from working. 

I have tried using this onchange client script but no luck. I am new to scripting.

if(choicevalue == 'IT'){

g_form.setValue('assignment_group','group_sys_id');

Thank you in advance.

1 ACCEPTED SOLUTION

That brings to mind the full onChange script has by default this bit at the beginning.

 if (isLoading || newValue == '') {
   return;
 }

This stops the script from running if the newValue is blank.  Sometimes you might want to remove the || newValue == '' part so that you can do something - like in this case if the choice is not mandatory, they could change it back to -- None -- which is stored as '', then you would want to clear the Assignment group.  To build out the script, you would want various else if blocks followed by an else to cover the scenario of multiple choice changes.

if(newValue == 'IT'){
  g_form.setValue('assignment_group','group_sys_id');
}
else if(newValue == 'Finance'){
  g_form.setValue('assignment_group','finance_group_sys_id');
}
else if(newValue == 'HR'){
  g_form.setValue('assignment_group','hr_group_sys_id');
}
else{
  g_form.clearValue('assignment_group');
}

  

View solution in original post

5 REPLIES 5

You are welcome.