What Is a Context Definition?
A Context Definition is a metadata-driven structure used to pass data into Revenue Cloud services in a consistent and reusable way. It is defined by a set of core building blocks -
- Nodes – Containers for attributes mapped to Salesforce objects. Each node can hold multiple attributes.
- Attributes – Containers for data, mapped directly to fields on an object.
- Context Tags – Simple aliases for nodes and attributes, used by consuming applications to query context data easily.
- Context Mappings – The link between nodes/attributes and input data sources. A single context definition can support multiple mappings to serve different use cases.
A context definition typically follows four stages:
- Creation (Design time) – Defining nodes, attributes, tags, and mappings.
- Hydration – Populating the definition with actual record data at runtime.
- Consumption – Querying or transforming hydrated data.
- Persistence – Writing any changes back into mapped objects.
Context Service APIs
The Context Service provides a set of Apex APIs to interact with context definitions. In this post, we’ll focus on hydration, retrieval, and querying.
- Build: Load data into a context.
- buildContext – Create a context instance at runtime.
- getContext – Retrieve details of an existing context.
- deleteContext – Delete a context instance.
- Query: Explore data within the context.
- queryContextRecordsAndChildren – Retrieve records and child records.
- queryTags – Retrieve tag values.
- Update: Modify an existing context.
- updateContextAttributes – Update data in the context.
- addRecordToContext – Add new data.
- Persist: Save context data back to the database.
- persistContext – Write hydrated context data to mapped objects.
Applications of Context Definitions
Context Definitions appear in many Revenue Cloud scenarios, including :
- Pricing Procedures – Passing quote and product information into the pricing engine.
- Product Discovery – Determining which products or services are eligible for a customer.
- Contracts & Assets – Handling renewals, asset-based ordering, and related conditions.
Consuming Context Definitions from Apex
From a developer’s perspective, consuming a Context Definition directly in Apex is useful when:
- Triggering Apex hooks within a procedure plan.
- Testing or validating changes made to a Context Definition.
- Building custom solutions that consume or share a hydrated context.
Instead of writing SOQL queries and reproducing mappings manually, you can rely on the Context Service APIs to tap into hydrated data directly.

No comments:
Post a Comment