Changes data

quotecloud_update_data_item_values

Set a document’s merge-field (data item) values by data-item id. Merge fields are tokens that resolve when the document is rendered, so this rewrites no rich text and touches no block: setting one value changes every place that field appears. Works the same on a document in either contentMode, because these values live in Convex in both. Two layers are written by default. documentValue is the document’s row in the company custom-data store, which quotecloud_get_custom_data_values returns, custom-field search matches, and validation reads first. override is the per-document value the renderer itself reads. Writing only one produces a document that disagrees with itself: only documentValue and the rendered document is unchanged; only override and the custom-data store still holds the old value: so use layers to name one deliberately. The document’s own default (the value it was created with) is never written, which is what makes value: null mean "fall back to that default" rather than "erase it". Read the current state with quotecloud_check_missing_merge_fields, whose dataItems array reports every data item with its id, type, allowed values, whether it is referenced in the content, its resolved value and which layer that came from. Values are checked against the item’s type: a number for number/currency, true/false for a yes/no or a check field, an ISO 8601 string for date (YYYY-MM-DD) and dateTime (YYYY-MM-DDTHH:MM(:SS) with an optional Z or ±HH:MM offset: a parseable but locale-dependent string such as "July 25, 2026" is refused because its meaning depends on who parses it), one of the item’s allowed values for a dropdown, and an array of allowed values for a multi-select. Only data items connected to document or template can be set here, and quotecloud_check_missing_merge_fields lists exactly that pair; a contact, product, user or contactDocumentLink item’s value belongs to that record rather than to the document and is refused. Acquires the editor lease and the settings lock, and every named data item is validated before either is taken.

Inputs

documentIdRequired
Convex document ID or company-scoped numeric display ID. string
valuesRequired
list of object
layersOptional
Which layers to write. Defaults to both, which is what keeps the rendered document and the custom-data store agreeing. list of one of: documentValue, override
lockTokenRequired
Stable opaque token for this agent edit session. Reuse it to heartbeat owned element locks. string