# Function
URL: /reference/blocks/system-function
Type: reference
Description: Run custom JavaScript code within your workflow
Keywords: function, system/function, system, block, workflow builder
`system/function` — Run custom JavaScript code within your workflow.

Where it appears [#where-it-appears]

The **Function** block lives in the **Logic & control** group of the Workflow Builder.

Fields [#fields]

| Field     | Type | Required | Default | Description                                                                                                                                                                                                                                                 |
| --------- | ---- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`    | code | Yes      | —       | JavaScript executed at this step. Reference any upstream output directly with `&lt;Node.field&gt;` — it resolves to the actual value (objects and arrays are preserved). `return` a value, which becomes this block's `result` output for downstream steps. |
| `timeout` | text | No       | `5000`  | Maximum execution time. Values above 10000ms are clamped.                                                                                                                                                                                                   |

Inputs and outputs [#inputs-and-outputs]

Inputs are the configurable fields above. The block produces these outputs:

**Outputs**

Reference an output downstream with `<Function.field>`.

| Name      | Type    | Description                                        |
| --------- | ------- | -------------------------------------------------- |
| `result`  | json    | Return value from the executed JavaScript function |
| `stdout`  | string  | Console log output from function execution         |
| `success` | boolean | Whether function executed successfully             |
| `error`   | string  | Error message if execution failed                  |

Example [#example]

A minimal configuration for this block:

```json
{
  "type": "system/function",
  "config": {
    "code": "...",
    "timeout": "5000"
  }
}
```

Limits and failure modes [#limits-and-failure-modes]

* Required field (`code`) must be set, or the block fails validation before it runs.
* On failure the `error` output is populated; downstream blocks that reference other outputs may not receive values.

Related [#related]

* [All workflow blocks](/reference/blocks)
* [Workflow Builder overview](/workflow-builder-overview)