execute_background_script
Execute server-side JavaScript in ServiceNow using Background Scripts to run custom code, automate processes, and interact with instance data within specified application scopes.
Instructions
Execute server-side JavaScript in ServiceNow using Background Scripts. ⚠️ SANDBOX ONLY - executes arbitrary code. 🛡️ Auto-truncates large outputs. 📁 Use {{file:path}} for large scripts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | The server-side JavaScript code to execute (e.g., gs.print("Hello");). Maximum 50,000 characters. Supports {{file:...}} placeholders to load content from local files. | |
| scope | Yes | The application scope (e.g., "global" or specific app scope). Required. | |
| timeout_ms | No | Optional timeout in milliseconds (default: 60000, range: 1000-300000) | |
| include_html | No | Include HTML output in response (default: true). Set to false for text-only mode to reduce response size. | |
| response_mode | No | Response verbosity: full (all data), minimal (essential only), compact (summarized). Default: full |