Rollups¶
Part of: ClientVerse Core (every client).
What it is¶
A declarative aggregation engine: roll child-record values up to a parent without writing Apex.
"How many active contacts does this account have?", "what is the total value of matters for this
client?", "how many distinct practice areas have we served them in?" — each is a Rollup
Definition (Rollup_Definition__c) an admin configures, not a development task.
Salesforce's native roll-up summary fields only work across master-detail relationships and offer a narrow set of functions. This engine works across lookups, supports filtering, and — since Core 1.1.6 — handles distinct counts and multi-hop relationship paths.
Who it's for¶
Admins. End users consume the numbers; they do not configure them. CV_Rollups_Admin gates
configuration, and it should stay with a small group: rollup definitions produce figures the whole
firm makes decisions on.
How it works¶
A definition specifies the parent object, the child object, the aggregation, the target field, and
optionally a filter (Rollup_Filter__c) restricting which children count.
Aggregation types¶
| Type | Use |
|---|---|
COUNT |
How many children |
SUM |
Total of a numeric child field |
MIN / MAX |
Earliest/latest, smallest/largest |
AVG |
Mean |
COUNT_DISTINCT |
How many unique values — (new in 1.1.6) |
COUNT_DISTINCT answers a genuinely different question from COUNT. "How many matters have we run
for this client" and "how many distinct practice areas have we served them in" need different
functions, and before 1.1.6 the second required custom code.
Relationship-path rollups (new in 1.1.6)¶
A rollup source no longer has to be a direct child. A definition can traverse a relationship path to reach its source records — so a figure that logically belongs on an Account but is stored two hops away no longer needs an intermediate helper field or a bespoke trigger.
Validation¶
Definitions are validated before they run: a mismatched aggregation and field type, or an unresolvable relationship path, is rejected at save rather than failing quietly at runtime. An admin gets the error while they are still looking at the configuration.
Recalculation¶
Rollups maintain themselves as records change, but drift is possible — a bulk data load or an integration writing through a path that bypasses the trigger can leave parents stale. A full recalculation reconciles a definition against reality.
Run one after any bulk data operation, after a migration, and whenever a figure looks wrong. If recalculation changes a value, the interesting question is what caused the drift, not just that it is now fixed.
How to use it¶
- Open Rollup Definitions in
CV_Admin. - Create a definition — parent, child, aggregation type, target field.
- Add a filter if only some children should count.
- Save (validation runs here) and activate.
- Verify against a parent record whose children you have counted by hand.
- Run a recalculation to populate existing records.
Step 5 is not optional. A rollup that returns a plausible-looking wrong number is more damaging than one that visibly fails, because nobody questions it. Always check a new definition against a manually-verified parent — and for
COUNT_DISTINCT, pick a parent that genuinely has duplicates, or the result is indistinguishable fromCOUNT.
Related¶
- Admin Guide — operating rollups day to day.
- Configuration Reference — field-level reference.
- QA coverage:
ROLincore-rollups.md.