create_block
Define a structured block on a sheet with typed fields, initial rows, and row-key column. Sets up tables for BLOCKREF/BLOCKREFS formulas and auto-creates the target sheet if missing.
Instructions
Create a structured block (table) on a sheet. fields[0] is the row-key column (always read-only). Block ref name (name) is used as the first arg to BLOCKREF/BLOCKREFS in formulas.
Field types supported:
'string' / 'number' — plain text/numeric cells.
'boolean' — cell stores 0/1 or TRUE/FALSE; UI renders ✅/❌ if host has the widget set.
'enum' (+ enum_id) — cell stores variant id; UI renders dropdown if host has the widget set. Watson auto-injects a variant-whitelist validation formula on the field so out-of-set writes light up as warnings even without widget rendering. Requires a prior define_enum_set call with matching id.
Rules (value_formula / validation / editability) are set separately via set_field_rule — this call only declares structure + initial rows. Auto-creates the target sheet if missing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Block ref name. Used as the first arg to BLOCKREF/BLOCKREFS in formulas. Must be unique within the workbook. | |
| sheet | Yes | Target sheet name. | |
| fields | Yes | Column definitions in order. fields[0] is the row-key column. | |
| position | Yes | Top-left cell of the block (0-indexed). | |
| initial_rows | No | Optional initial rows. |