Auto-populate Related Fields
Automatically populate fields when a reference field changes (e.g., populate caller's phone and email when caller is selected).
View script ↗The script library
ServiceNow code examples to read, adapt, and test in your development instance.

54 scripts
Automatically populate fields when a reference field changes (e.g., populate caller's phone and email when caller is selected).
View script ↗Make fields mandatory based on the value of another field (e.g., require close notes only when state is Resolved).
View script ↗Show or hide fields based on another field's value (e.g., show "Other reason" field only when user selects "Other" from dropdown).
View script ↗Filter options in a reference field based on another field's value (e.g., show only assignment groups for the selected category).
View script ↗Validate form data and prevent submission if conditions aren't met (e.g., prevent closing ticket without resolution notes).
View script ↗Call server-side Script Include from client-side to fetch data or perform operations without page refresh.
View script ↗Validate field input in real-time and provide immediate feedback to users (e.g., check format, valid values, etc.).
View script ↗Show a confirmation dialog before saving the form when certain conditions are met (e.g., warn user about critical changes).
View script ↗Automatically populate form fields with the current logged-in user's information (e.g., pre-fill requester details).
View script ↗Automatically calculate field values based on other fields (e.g., calculate total cost, days between dates, percentage).
View script ↗Show or hide sections or specific fields based on the current user's roles, useful for restricting sensitive information access.
View script ↗Implement a debounced search to avoid excessive server calls when users type in a search field, improving performance.
View script ↗Validate combinations of multiple fields together, such as ensuring end date is after start date or validating business logic across fields.
View script ↗Periodically save form data automatically to prevent data loss if browser crashes or session expires.
View script ↗Show contextual help text or tooltips for specific fields to guide users, with ability to toggle help on/off.
View script ↗Disable the submit button after first click to prevent duplicate record creation from double-clicks or multiple submissions.
View script ↗Validate date fields against each other with custom business rules like working days, blackout periods, and lead times.
View script ↗Automatically assign tickets to the appropriate assignment group based on category.
View script ↗Send customized email notifications when specific conditions are met.
View script ↗Automatically populate fields with default values or calculated values when a record is created.
View script ↗Check for existing records and prevent duplicates based on specific field combinations.
View script ↗Automatically update related records when the parent record status changes (e.g., resolve all child tasks when parent is resolved).
View script ↗Automatically create related records when certain conditions are met (e.g., create change request when major incident is detected).
View script ↗Automatically calculate SLA due dates based on priority, business hours, and update SLA status.
View script ↗Automatically create approval records and request approvals when certain conditions are met (e.g., high-cost purchases, major changes).
View script ↗Create detailed audit trail records when sensitive fields are modified, maintaining compliance and tracking changes.
View script ↗Send data to external systems via REST API webhooks when records are created or updated (e.g., Slack, Teams, third-party systems).
View script ↗Limit which records users can see based on custom criteria like location, department, or assignment group membership.
View script ↗Calculate and display values on forms without modifying the database, useful for showing metrics, totals, or derived information.
View script ↗Send notifications asynchronously based on complex business logic, preventing delays in record save operations.
View script ↗Automatically update related child records when parent record changes, maintaining data consistency across relationships.
View script ↗Generate custom record numbers with prefixes based on category, type, or other fields (e.g., HW0001, SW0002, NET0003).
View script ↗Provide server-side functions that can be called from Client Scripts via GlideAjax.
View script ↗Reusable functions for date and time calculations and formatting.
View script ↗Reusable functions for user and group operations.
View script ↗Reusable functions for string operations and text processing.
View script ↗Reusable functions for validating data and enforcing business rules.
View script ↗Simplified and safe GlideRecord operations with error handling.
View script ↗Reusable functions for making REST API calls to external systems with error handling and authentication.
View script ↗Reusable functions for working with Configuration Items (CIs) in the CMDB.
View script ↗A comprehensive Script Include demonstrating multiple client-callable functions in a single utility class.
View script ↗Reusable functions for common date and time calculations, business days, and formatting.
View script ↗Reusable functions for common string operations, formatting, and transformations.
View script ↗Standardized functions for formatting and handling REST API responses with consistent error handling.
View script ↗Efficient GlideRecord query patterns with built-in best practices, error handling, and common operations.
View script ↗Add a list button to update multiple selected records at once with custom logic.
View script ↗Add a form button to create a copy of the current record with all field values.
View script ↗Add a form button to export the current record to a PDF document.
View script ↗Add a form button to trigger approval workflow with validation.
View script ↗Add a form button to open a popup showing related records from another table.
View script ↗Update multiple selected list records with custom field values, useful for mass updates.
View script ↗Export selected list records to CSV file with custom field selection.
View script ↗Deep copy a record including related child records like tasks, attachments, and notes.
View script ↗Trigger a custom approval workflow with validation and user selection of approvers.
View script ↗