execute_background_script
Run server-side JavaScript on the instance and return what it returns. The script runs in the global scope inside a run-once Scheduled Script Execution (ServiceNow has no REST endpoint that runs scripts synchronously), so it executes when…
Instructions
Run server-side JavaScript on the instance and return what it returns. The script runs in the global scope inside a run-once Scheduled Script Execution (ServiceNow has no REST endpoint that runs scripts synchronously), so it executes when the instance scheduler picks the job up, normally within seconds. End the script with return <value>; to get a value back (JSON-serialisable; max ~3.5 KB). [Scripting]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JavaScript to execute (max 6000 chars). It is wrapped in a function, so `return` works. | |
| wait_seconds | No | How long to wait for the job to run (0-120, default 30). If the scheduler has not run it by then, script_scheduled is returned with the job. |