---
title: "form.setScript: Set a field's JavaScript — PDF kit command — Kition"
description: "Field Properties ▸ Run custom script: set field's JavaScript for event keystroke, format, validate or calculate (the field's actions; calculated fields join the calculation order) or mouse_up (a button's action). Omit script to remove it. The scripts use the Acrobat JavaScript object model (event.value, event.rc, getField, util.printf, …) and run when the field changes. Undoable."
canonical: "https://developer.kition.ai/docs/kits/pdf/commands/form.setScript"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/pdf/commands/form.setScript](https://developer.kition.ai/docs/kits/pdf/commands/form.setScript)

# form.setScript

**Set a field's JavaScript.** Field Properties ▸ Run custom script: set field's JavaScript for event keystroke, format, validate or calculate (the field's actions; calculated fields join the calculation order) or mouse_up (a button's action). Omit script to remove it. The scripts use the Acrobat JavaScript object model (event.value, event.rc, getField, util.printf, …) and run when the field changes. Undoable.

- Kit: PDF 0.1.0 (.pdf); reference: [PDF kit commands](https://developer.kition.ai/docs/kits/pdf.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | `"keystroke" \| "format" \| "validate" \| "calculate" \| "mouse_up"` | yes |  |
| `field` | `string` | yes |  |
| `script` | `string` | no |  |

## Call through pdf_run

```text
pdf_run {
  "path": "<file>.pdf",
  "steps": [{ "command": "form.setScript", "params": { "event": <"keystroke" | "format" | "validate" | "calculate" | "mouse_up">, "field": <string> } }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `script`. pdf_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "event": {
      "enum": [
        "keystroke",
        "format",
        "validate",
        "calculate",
        "mouse_up"
      ],
      "type": "string"
    },
    "field": {
      "type": "string"
    },
    "script": {
      "type": "string"
    }
  },
  "required": [
    "event",
    "field"
  ],
  "type": "object"
}
```

Generated from the command list of @kition/pdf-darwin-arm64@0.1.0 and the kit itself (pdf_commands through @kition/cli@0.1.1, built from KitionAI/kition-pdf@b0d2725).
