record_write
Create, update, or delete a record in ServiceNow. Includes preview mode and script field handling.
Instructions
Create, update, or delete a record. Defaults to preview mode.
Script-bearing tables (Business Rules, Script Includes, widgets, etc.)
are not special-cased - script-field discovery happens at runtime via
sys_dictionary and the table's super_class chain. script_path
loads a local file into the resolved target field; script_field
names the destination column when more than one script-bearing field
is detected.
Args:
action: 'create' | 'update' | 'delete'.
table: Target table. Required.
sys_id: Required for 'update' and 'delete'.
data: JSON string of field values. Required for 'create' and
'update'.
script_path: Optional absolute path to a local script file. Content
is read (UTF-8, max 1 MB) and stored under the resolved
target script field. Path resolved with strict=True;
constrained to settings.script_allowed_root. When the
resolved field has internal_type == 'xml', the content is
validated as well-formed XML before any platform call.
script_field: Optional override for the destination script field.
When empty (default), the first detected script field is used
(child-first, sys_dictionary row order within a table).
When set, must match one of the script-bearing fields detected
from sys_dictionary; otherwise the call returns a
structured error listing the detected fields. Use
describe(action='list_script_fields', table=...) to
discover script fields for a table.
preview: When True (default) returns a preview_token; caller
invokes record_apply to commit. When False, write commits
immediately.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| table | No | ||
| sys_id | No | ||
| data | No | ||
| script_path | No | ||
| script_field | No | ||
| preview | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |