Other Server-side Script Types
In this module you have learned to write, test, and
debug Business Rules and Script Includes. There are many other types of
server-side scripts. The primary difference between the script types is
what triggers the script logic execution.
The table shows some commonly used server-side script types.
Script Type | Executes on | Description | Often used to |
---|---|---|---|
Business Rule | Database access | Execute logic when records are queried, updated, inserted, or deleted. | Validate data or set fields on other records in response to fields on the current record. |
Script Include | Must be explicitly called | A library of reusable functions. | Validate format, retrieve shared records, and work with application properties. |
Script Action | Events | Respond to an event. | Send email notifications or write logging information. |
Scheduled Script Execution (also known as a Scheduled Job) | Time | Script logic executed on a time-based schedule. | Create reports: send daily, weekly, monthly, quarterly, and annual information. Execute script logic only on weekdays or weekends. Can also be run on demand so sometimes used for testing. |
UI Actions | Users | Add buttons, links, and context menu items to forms and list to allow users to perform application-specific operations. | Enable users to perform actions such as navigating to another page, modifying records, or allowing operations such as saving. |
Scripts - Background | admin users only (some instances require the security_admin role) | Execute server-side code on demand from a selectable scope. Scripts - Background should be used with caution because badly written scripts can damage the database. | Test scripts. |
Fix Scripts | Application installation or upgrade | Make changes that are necessary for the data integrity or product stability. | Create or modify groups or user authorizations. |
Notification Email Script | Notification | Execute when emails are generated to add content to the email content or configuration. | Add a CC or BCC email address, or query the database and write information to the message body. |
Scripted REST APIs | Request sent or received through web services | Defines a web service endpoint | Return value(s) or a JSON object based on a calculation or database lookup(s) |
UI Page Processing Script | Users | Executes when a UI Page is submitted. | Validating data, setting values etc. |
Transform Map Script | Data import | Modifies or copies data or data format when records are imported. | Standardize date formats, fill in missing data, standardize values, map incoming values to database values for choice lists, set default values. |
You can practice using additional server-side script types in other courses and modules on the ServiceNow developer site.