What This Table Is
The sys_script table contains Business Rule definitions - the metadata that tells ServiceNow when and how to execute server-side JavaScript during database operations. Each record defines a script that can fire before, after, on display, or asynchronously when records are inserted, updated, deleted, or queried on specific tables.
This table is owned by the System Definition module and serves as the foundation for all server-side automation in ServiceNow. Business Rules defined here execute automatically based on database events, making them crucial for data validation, calculations, integrations, and workflow automation across the entire platform.
The sys_script table extends sys_metadata and inherits standard metadata fields for application scoping, update sets, and version control. No tables extend sys_script directly, but it references many tables through its collection field that specifies which table the Business Rule applies to.
Large enterprises typically have 3,000-8,000 Business Rules across all applications. Performance is generally excellent for queries by collection (indexed) but can be slow when searching script content or advanced conditions. The platform caches active Business Rules aggressively, so metadata changes require cache clearing to take effect.
When You'll Script Against This Table
You'll primarily query sys_script in Script Includes for dynamic rule discovery, in Business Rules that need to check other rules, and in scheduled jobs that audit or manage Business Rule configurations. Administrative interfaces and custom applications also query this table to display rule information or validate configurations.
Access requires the admin role for full read/write access, though scoped applications can read their own Business Rules with appropriate delegated development roles. The table respects application scope boundaries - global scripts can see all rules, but scoped applications only see their own.
- Finding all Business Rules that execute on a specific table for impact analysis
- Searching script content to locate rules using specific APIs or field references
- Auditing rule execution timing and conditions to optimize performance
- Dynamically enabling/disabling Business Rules based on system conditions
- Building custom admin interfaces that manage or report on Business Rule configurations
- Creating deployment scripts that validate Business Rule dependencies
- Implementing rule execution monitoring and alerting for critical automations
Table Gotchas
Business Rules are cached aggressively. Changes to sys_script records don't take effect until the cache is cleared or the instance is restarted. Always test rule changes after modifying this table directly.
- The
collectionfield stores the table name as a string, not a reference - query using string values, not sys_ids
The 'when' field uses integer values: 'before'=1, 'after'=2, 'async'=4, 'display'=8. Multiple timings are bitwise OR'd together, so a rule with before+after timing has when=3.
- Advanced conditions in the
conditionfield use encoded condition strings - not directly readable without parsing - Queries against the
scriptfield (script content) are extremely slow on large instances - avoid CONTAINS queries in production
Business Rules marked as 'Global' (is_rest=false) execute for all database operations on their table, including integrations and bulk operations. This can cause unexpected performance issues.
- The
orderfield controls execution sequence but only within the same timing (before/after/async) - before rules always run before after rules regardless of order
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Related Tables
The sys_script table extends sys_metadata, inheriting application scoping and update set tracking capabilities. This relationship is crucial for understanding how Business Rules are packaged and deployed across instances. The sys_scope field links to application records for scoped Business Rules.
Business Rules commonly reference sys_db_object through their collection field to determine which tables they execute against. The sys_user table is frequently joined when auditing who created or modified Business Rules. For debugging and monitoring, developers often correlate sys_script records with execution logs in syslog or syslog_transaction tables.
When building comprehensive automation reports or impact analysis tools, developers typically join sys_script with related automation tables like wf_workflow (workflows), sys_ui_action (UI actions), and sys_script_include (Script Includes) to understand the complete automation landscape for a given table or application.