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 | 
Input Schema (JSON Schema)
{
  "properties": {
    "include_html": {
      "description": "Include HTML output in response (default: true). Set to false for text-only mode to reduce response size.",
      "type": "boolean"
    },
    "response_mode": {
      "description": "Response verbosity: full (all data), minimal (essential only), compact (summarized). Default: full",
      "enum": [
        "full",
        "minimal",
        "compact"
      ],
      "type": "string"
    },
    "scope": {
      "description": "The application scope (e.g., \"global\" or specific app scope). Required.",
      "type": "string"
    },
    "script": {
      "description": "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.",
      "type": "string"
    },
    "timeout_ms": {
      "description": "Optional timeout in milliseconds (default: 60000, range: 1000-300000)",
      "type": "number"
    }
  },
  "required": [
    "script",
    "scope"
  ],
  "type": "object"
}