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

Robert Beeman
Kilo Sage

You can set it with client script with g_form.setValue like this


g_form.setValue('variable_name', 'sys_id of group');



Reference: GlideForm (g form) - ServiceNow Wiki


Hi Robert,



There's a third argument that needs to be filled in when setting reference fields with g_form.setValue().



g_form.setValue('fieldname', sys_id, displayValue);



Most people forget the third one which causes the client to make a (synchronous) request back to the server which can cause delays.


never noticed that myself.   Great tip


Chuck Tomasi
Tera Patron

Hi Ronald,



I would disagree with whomever told you that a client script is best practice. It's a bit more complex.



The easiest way is from the dictionary (as a default value or dictionary override to the default value).



System Dictionary - ServiceNow Wiki


Dictionary Overrides - ServiceNow Wiki