Define rollup
define_rollupCreate a derived-metric rollup that aggregates a custom source object onto a target field (e.g. usage_revenue = sum of usage records onto an account field). agg is sum/count/avg/min/max. The source must be a custom object; ARR/renewal fields are system-owned and can't be targets. Returns the created rollup. An existing rollup is edited with update_record / delete_record on object_type "rollup" (its id and key come from describe_schema).
When to use: When an admin wants a computed field — e.g. usage revenue summed from usage records onto the account.
Example: Roll up usage records into a usage_revenue field on the account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agg | Yes | Aggregation: sum, count, avg, min or max. Every kind except count needs agg_field. | |
| key | Yes | Stable name for the rollup, slugified to lowercase/underscores; unique per workspace. | |
| agg_field | No | The numeric source field key to aggregate; required unless agg is count (null then). For an account source only current_arr_cents. | |
| filter_spec | No | Optional numeric filters on source records, [{key, op, value}] with op one of eq/neq/gt/gte/lt/lte; key is a source data key, value a number (non-numeric clauses are skipped). Not supported when source_object is account. | |
| source_link | Yes | The relationship field key on the source whose value is the target record's id — it decides which source records roll up to each target. | |
| target_field | Yes | Field key on the target that stores the result (a custom field on a built-in target, a data key on a custom one); current_arr_cents and renewal_due_at are refused. | |
| source_object | Yes | Object whose records are aggregated: a custom object, or account (then agg_field may only be current_arr_cents). | |
| target_object | Yes | Object key whose records receive the value — a built-in one (account, contact, opportunity, subscription, touch, signal, task) or a custom object. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rollup | No |