Elements
Metrics, formulas, filters, and enrichments make up one library — the element library. Each is a reusable piece of context: define it once, add it by API name to any number of entities.
The four types
| Metric | Formula | Filter | Enrichment | |
|---|---|---|---|---|
| Produces | A rollup over related records | A computed value from the record | A named, reusable condition | Values and/or record tables |
| Cost | Batched into one query | None — no query | None — it shapes queries | A query or more, per record |
| Default minimum level | list | list | — (not rendered) | detailed |
| Defined by | Relationship + function + filters | A formula expression | Conditions on the object | A source: Apex, invocable, or flow |
Metrics, formulas, and enrichments put values on the payload. A filter never appears there. It belongs to the entity’s query contract: an agent passes its API name to Find Records and ContextWorks applies the condition. See Named filters.
Every element carries these properties:
| Property | What it holds |
|---|---|
| Label | What the payload calls the value |
| API name | How entities refer to the element. You can’t change it after you create it |
| Instruction | Optional. ContextWorks renders it with the value |
| Synonyms | Optional |
| Minimum level | The leanest level the element appears in |
| Available for | Which objects you may use the element on. Empty means any |
| Where used | The entities that use it |
Define once, use many times
One definition serves many entities. Change a metric’s filter and every entity using it returns the new result on its next call — no second copy to find, nothing to activate.
Entities are versioned; elements are not. A version freezes which elements an entity uses, never what they compute. An element’s edit dialog warns you when more than one entity uses it.
Add an element to an entity outside its Available for list and ContextWorks skips that element, logs a warning on the Issues page, and delivers the rest of the payload.
Metrics
A rollup over child records: count, sum, average, min or max, with optional filters. For example, SUM of Opportunities.Amount where IsClosed = false.
Metrics default to list level: one number answers how many or how much better than twenty-five rows. ContextWorks batches every metric on a payload into one query, so ten cost roughly what one costs. → Building metrics
Formulas
A standard Salesforce formula ContextWorks evaluates against the record it already loaded: Amount * Probability / 100. No extra query, and ContextWorks adds any field the expression names to the entity’s query for you. Percent fields evaluate as fractions, so 100% is 1.0. → Building formulas
Filters
A named condition you write once — open, committed — so an agent asking for open opportunities gets your definition of open rather than its own guess.
ContextWorks advertises each filter in the catalog with its meaning, and combines filters with AND in Find Records. A filter may use fields an agent can’t filter on individually, because you wrote the condition rather than the caller. See Named filters.
Enrichments
Computed context from a source:
| Source | What it mounts |
|---|---|
| Apex Provider | A class implementing EntityEnrichmentProvider. Also how a Data 360 DTO registers |
| Invocable Action | Any existing @InvocableMethod, unchanged |
| Flow | Any active autolaunched flow, unchanged |
| Data 360 (planned) | Declarative queries over Data 360 objects |
| External Objects (planned) | OData-backed __x objects |
An enrichment returns labeled values or record tables. ContextWorks re-queries record results as the calling user. When a source fails, the payload still arrives without that enrichment, and the failure shows up on Issues. → Building enrichments · Provider SPI
Choosing between them
| You want… | Use |
|---|---|
| A count or total over child records | Metric |
| Arithmetic over fields on this record | Formula |
| A business word agents can filter by — “open”, “committed” | Filter |
| The actual child rows | Related list — not an element |
| A value only your code can compute | Enrichment (Apex provider) |
| Something an existing flow or action already returns | Enrichment (flow or invocable) |
| A parent record’s details inline | Reference — not an element |
If a metric and a formula could both produce it, prefer the formula — it costs no query.