Client script to set default assignment group

Anna L
Tera Contributor

When an incident is created, default assignment group should be set as "IT Systems". I was told that the best practice is to create a client script instead of setting the default value in form design.

Can anyone share script (screenshot) and suggestions?

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

Client scripts are subject to the whim of the client browser.   I think it is best practice to move as much of the processing as you can to the server.   I would not go Client Script here.



I would do the before insert that was suggested above.



find_real_file.png


View solution in original post

15 REPLIES 15

we had a problem where we were using a new table extended from TASK, so we could not use the sys_dictionary defaults


additionally, the field was required on a null form so a BR really wouldn't do the trick either...


and because we have so few client scripts running now (and the audience for the application is 6 users), we felt that a client script was the best way to go...



our script:



function onLoad() {


var ag = g_form.getValue('assignment_group');


  if (ag == '')


  {


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


  g_form.setReadOnly('assignment_group',true);


  }


}



Of course, using a hard coded SYS_ID is also not suggested, however our assignment group is the servicenow development team...so if that group goes away, servicenow will pretty much go away too (not likely).



I look forward to explaining this decision when we review our next ACE report