Skip to content

Code fields

A code field runs a snippet of JavaScript for each row, with the row’s other fields available as input, and stores the returned value. It’s for logic that’s beyond a formula — parsing, custom formatting, multi-step calculations.

Code runs inside a secure sandbox (a QuickJS WebAssembly isolate): no network, no filesystem, no access to the host. It’s read-only like all computed fields, and recomputes automatically when the row changes.

// Row values are available on `fields`
return fields.Price * fields.Qty;

Your snippet’s result is the cell’s value. You can either return a bare expression’s value or use an explicit return:

// Bare expression — its value is the result
fields.Price * fields.Qty
// Or multi-line with an explicit return
const subtotal = fields.Price * fields.Qty;
const withTax = subtotal * 1.2;
return Math.round(withTax * 100) / 100;
  • fields — an object of the row’s values keyed by field name: fields.Name, fields["Unit Price"].
  • record.fields — the same object, if you prefer the fuller form.

Missing/blank values come through as null.

  • Strings, numbers, and booleans are stored as-is.
  • Objects and arrays are stored as their JSON string.
  • undefined / null store as an empty cell.
  • Output is capped at 10,000 characters.
// Format a phone number
const d = String(fields.Phone || "").replace(/\D/g, "");
return d.length === 10 ? `(${d.slice(0,3)}) ${d.slice(3,6)}-${d.slice(6)}` : fields.Phone;

Code fields are safe by construction:

  • No host accessfetch, process, require, import, and the filesystem are all unavailable.
  • CPU limit — each run is interrupted after 1 second, so an infinite loop can’t hang anything.
  • Memory limit16 MB per run; a runaway allocation is capped.
  • Output limit — results are truncated at 10,000 characters.

If your code throws or exceeds a limit, the cell is left blank and the failure is recorded in the run log.

Unlike formulas and templates (which recompute instantly as you type in a cell), code runs asynchronously — a moment after a write — because the sandbox runs server-side. In practice the value appears a beat after you change an input.

Ordering: formula and template fields compute first, then code. So:

  • A code field can read a formula’s or template’s up-to-date value.
  • A formula that reads a code field’s value picks it up on the next write to the row.
  • Chained code fields may lag one write behind.
  • Read-only and materialized — filtering, sorting, API reads, and public shares all see the computed value.
  • Same-row only — code sees the current row’s fields, not other rows or linked records.
  • Deterministic use recommended — since results are stored, prefer logic that depends only on the row’s inputs.