ServiceNow Scripts Library
A comprehensive collection of ready-to-use ServiceNow scripts for common use cases. Search, filter, copy, and customize these battle-tested solutions.
Client Scripts
Client Scripts run in the user's browser and control form behavior in real-time. Use them for UI manipulation, field validation, and user interaction.
Auto-populate Related Fields
Automatically populate fields when a reference field changes (e.g., populate caller's phone and email when caller is selected).
Conditional Mandatory Fields
Make fields mandatory based on the value of another field (e.g., require close notes only when state is Resolved).
Dynamic Field Visibility
Show or hide fields based on another field's value (e.g., show "Other reason" field only when user selects "Other" from dropdown).
Reference Field Filtering
Filter options in a reference field based on another field's value (e.g., show only assignment groups for the selected category).
Prevent Form Submission
Validate form data and prevent submission if conditions aren't met (e.g., prevent closing ticket without resolution notes).
GlideAjax Server Call
Call server-side Script Include from client-side to fetch data or perform operations without page refresh.
Real-time Field Validation
Validate field input in real-time and provide immediate feedback to users (e.g., check format, valid values, etc.).
Confirmation Dialog Before Save
Show a confirmation dialog before saving the form when certain conditions are met (e.g., warn user about critical changes).
Populate Fields from Current User
Automatically populate form fields with the current logged-in user's information (e.g., pre-fill requester details).
Calculate Field Values Dynamically
Automatically calculate field values based on other fields (e.g., calculate total cost, days between dates, percentage).
Role-based Section/Field Visibility
Show or hide sections or specific fields based on the current user's roles, useful for restricting sensitive information access.
Debounced Search with GlideAjax
Implement a debounced search to avoid excessive server calls when users type in a search field, improving performance.
Multi-field Dependent Validation
Validate combinations of multiple fields together, such as ensuring end date is after start date or validating business logic across fields.
Auto-save Draft Functionality
Periodically save form data automatically to prevent data loss if browser crashes or session expires.
Field Help Text Toggler
Show contextual help text or tooltips for specific fields to guide users, with ability to toggle help on/off.
Prevent Duplicate Submission
Disable the submit button after first click to prevent duplicate record creation from double-clicks or multiple submissions.
Custom Date Range Validation
Validate date fields against each other with custom business rules like working days, blackout periods, and lead times.
ACL Debug Visualizer
Business Rules
Business Rules run on the server when records are inserted, updated, deleted, or queried. Use them for data validation, automation, and integrations.
Auto-assign Based on Category
Automatically assign tickets to the appropriate assignment group based on category.
Send Email Notifications
Send customized email notifications when specific conditions are met.
Populate Fields on Insert
Automatically populate fields with default values or calculated values when a record is created.
Prevent Duplicate Records
Check for existing records and prevent duplicates based on specific field combinations.
Cascade Status Updates
Automatically update related records when the parent record status changes (e.g., resolve all child tasks when parent is resolved).
Create Related Records
Automatically create related records when certain conditions are met (e.g., create change request when major incident is detected).
Calculate and Update SLA
Automatically calculate SLA due dates based on priority, business hours, and update SLA status.
Create Approval Records
Automatically create approval records and request approvals when certain conditions are met (e.g., high-cost purchases, major changes).
Audit Trail and Change Logging
Create detailed audit trail records when sensitive fields are modified, maintaining compliance and tracking changes.
Integrate with External System (Webhook)
Send data to external systems via REST API webhooks when records are created or updated (e.g., Slack, Teams, third-party systems).
Query Business Rule - Restrict Visible Records
Limit which records users can see based on custom criteria like location, department, or assignment group membership.
Display Business Rule - Calculate Values
Calculate and display values on forms without modifying the database, useful for showing metrics, totals, or derived information.
Async Notification with Complex Conditions
Send notifications asynchronously based on complex business logic, preventing delays in record save operations.
Cascade Update to Child Records
Automatically update related child records when parent record changes, maintaining data consistency across relationships.
Auto-numbering with Custom Prefix
Generate custom record numbers with prefixes based on category, type, or other fields (e.g., HW0001, SW0002, NET0003).
Service Catalog Auto-Create Fulfillment Tasks
Automatically create fulfillment tasks for specific catalog items when requests are submitted, enabling multi-step approval and delivery workflows.
CMDB Data Governance Analyzer
Script Includes
Script Includes contain reusable server-side code that can be called from Business Rules, other Script Includes, or client-side via GlideAjax.
GlideAjax Response Handler
Provide server-side functions that can be called from Client Scripts via GlideAjax.
Date/Time Utilities
Reusable functions for date and time calculations and formatting.
User and Group Utilities
Reusable functions for user and group operations.
String Manipulation Utilities
Reusable functions for string operations and text processing.
Data Validation Utilities
Reusable functions for validating data and enforcing business rules.
GlideRecord Helper Functions
Simplified and safe GlideRecord operations with error handling.
REST API Client Utilities
Reusable functions for making REST API calls to external systems with error handling and authentication.
CMDB Utilities
Reusable functions for working with Configuration Items (CIs) in the CMDB.
GlideAjax Utility with Multiple Functions
A comprehensive Script Include demonstrating multiple client-callable functions in a single utility class.
Date Calculation Utility
Reusable functions for common date and time calculations, business days, and formatting.
String Manipulation Utility
Reusable functions for common string operations, formatting, and transformations.
REST API Response Helper
Standardized functions for formatting and handling REST API responses with consistent error handling.
Scheduled Job Utility Framework
Comprehensive framework for scheduled maintenance tasks including data cleanup, notifications, system health checks, and automated maintenance operations.
Record Query Utility
Efficient GlideRecord query patterns with built-in best practices, error handling, and common operations.
ACL Performance Analyzer
UI Actions
UI Actions are buttons, links, and context menu items that appear on forms and lists. Use them to provide custom functionality and improve user workflows.
Bulk Update Selected Records
Add a list button to update multiple selected records at once with custom logic.
Copy Record Button
Add a form button to create a copy of the current record with all field values.
Export Record to PDF
Add a form button to export the current record to a PDF document.
Send for Approval Button
Add a form button to trigger approval workflow with validation.
Show Related Records
Add a form button to open a popup showing related records from another table.
Bulk Update Selected Records (List Action)
Update multiple selected list records with custom field values, useful for mass updates.
Export to CSV (List Action)
Export selected list records to CSV file with custom field selection.
Clone Record with Related Items
Deep copy a record including related child records like tasks, attachments, and notes.
Manually Trigger Approval Process
Trigger a custom approval workflow with validation and user selection of approvers.
Bulk Status Transition with Validation
Scheduled Jobs
Automated background jobs that run on defined schedules to perform maintenance, data processing, and system health checks.
Audit Log Archive Manager
Archives old audit records to a history table and purges entries beyond the retention window to maintain system performance.