Sunday, 26 October 2025

Context Definition (RCA)


 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 -

  1. Nodes – Containers for attributes mapped to Salesforce objects. Each node can hold multiple attributes.
  2. Attributes – Containers for data, mapped directly to fields on an object.
  3. Context Tags – Simple aliases for nodes and attributes, used by consuming applications to query context data easily.
  4. 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:

  1. Creation (Design time) – Defining nodes, attributes, tags, and mappings.
  2. Hydration – Populating the definition with actual record data at runtime.
  3. Consumption – Querying or transforming hydrated data.
  4. 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