execute_script
Run server-side scripts on ServiceNow to execute complex queries using GlideRecord, GlideQuery, or GlideAggregate. Get script output directly from the instance.
Instructions
Execute a server-side script on the ServiceNow instance (Background Script). Supports GlideRecord, GlideQuery, GlideAggregate, and all server-side APIs. Returns the script output. Use for complex queries that cannot be expressed via REST. REQUIRES WRITE_ENABLED=true.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"script": "<script>"
},
"name": "execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | Application scope to run in (default: global) | |
| script | Yes | Server-side JavaScript to execute. Use gs.print() or gs.info() for output. |