Client-side programming is often preferred by users, due to the immediate interactivity of the scripts. Server-side programming is often preferred by developers due to eased complexity and better performance.
Let's look into what both types are and their advantages and disadvantages.
Types of client scripts
- onLoad(): Runs when a form is loaded.
- onChange(): Runs when a particular widget changes value.
- onSubmit(): Runs when a form is submitted.
- onCellEdit(): Runs when a cell on a list changes value.
A full list of all the places ServiceNow uses Client scripting can be found on the ServiceNow Client Scripting Wiki
- Can run immediately on field change or form load
- Can provide interactive windows with AJAX
- No sequencing for client scripts running on same table
- Can affect performance
- Can be more difficult to write than server-side programming such as business rules
- Limited GlideRecord queries (Should use GlideAjax instead)
- No access to certain ServiceNow libraries such as GlideSystem
- Can be affected by the type of browser used
- Limited database calls should be utilized due to performance
Client Script Wiki Articles
ServiceNow uses server-side scripting in areas such as:
- Business Rules
- Script Includes
- Script Actions
- Reference Qualifiers
- Transform Map Scripts
- Workflow Scripting
A full list of all the places ServiceNow uses Server scripting can be found on the ServiceNow Server Scripting Wiki
- Performance. When running code on the server, it often has a faster load time and processing time than a client script
- Not affected by type of browser
- Can perform complex database lookups
- Can dot-walk many levels, however three levels is often a recommend maximum
- Not as interactive as client scripts, needs an event like save, delete, or display to run
Server-side Script Wiki Articles