generate_script
Generate production-ready ServiceNow scripts with industry best practices for business rules, client scripts, scripted REST APIs, and more. Returns ready-to-deploy code with a best-practice checklist.
Instructions
Generate a complete, production-ready ServiceNow script with industry best practices baked in.
Supported types: business_rule — Server-side BR with guard, try/catch, async option script_include — Prototype-class SI with JSDoc and error envelope client_script — onChange/onLoad/onSubmit/onCellEdit with safe patterns ui_action — Server or client UI Action with redirect/confirm flow scripted_rest — Full Scripted REST API with auth, logging, error envelope scheduled_job — Scheduled job with timing, batch counting, error logging fix_script — One-time data fix with dry-run support and audit log widget — Service Portal widget stub (template + server + client)
Returns ready-to-deploy script code plus best-practice checklist and deploy field values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | ||
| name | Yes | Script name | |
| table | No | Target table (required for BR, CS, UI Action, Fix Script) | |
| description | No | What this script does | |
| logic | No | Core logic to embed (pseudo-code or partial code is fine) | |
| when | No | after | |
| events | No | ||
| condition | No | Encoded query condition | |
| async | No | ||
| methods | No | ||
| client_callable | No | ||
| script_type | No | ||
| field | No | Field name for onChange scripts | |
| client | No | ||
| hint | No | ||
| api_path | No | ||
| verb | No | GET | |
| requires_auth | No | ||
| request_params | No | ||
| schedule | No | daily | |
| query | No | Encoded query to select records to fix | |
| dry_run | No |