Skip to main content

Explore Context Service Components and Processes

Learning Objectives

After completing this unit, you’ll be able to:

  • Define the Context Service data model.
  • Describe the Context Service components.
  • Explain the Context Service design-time process.
  • Describe the Context Service run-time process.

The Context Service Logical Data Model

In Context Service, you configure the relevant data and its relationships to execute a digital process. An example of a digital process is processing a loan application by a bank, for which the bank needs different data. This data includes the applicant's name, job, income, credit history, collateral, and guarantors. Context Service creates a logical data model that consists of all the data you need for a digital process, no matter where the data comes from. The logical data model can then abstract and serve the relevant data to digital processes.

Context Service Components

Context Service consists of various components that you can use to source and serve ‌data to applications. Learn more about each of these components next.

Context Definition

A context definition models the complete set of information that you ‌require to execute a particular process. A context structure is a section in the definition that lists the nodes of the data model and their corresponding attributes. The definition uses mappings to define the relationship between the context structure and the source object data.

Here’s the Context Definitions page showing a list of existing custom definitions.

The list of custom context definitions with the New button and additional actions.

Create context definitions using the New button on the context definitions page. Click Additional actions beside each definition to view additional actions.

Context Service provides two types of context definitions. Identify your requirements clearly and use the definition that’s applicable.

  • Standard Definitions: Salesforce Industry Clouds provide a set of prebuilt context definitions that you can use in your workflows. You can't modify a standard definition’s components.
  • Custom Definitions: If the standard definitions don’t meet your business requirements, you can create custom definitions using any of these methods.
    • Start from Scratch: Create a custom definition from scratch by creating new nodes, attributes, tags, and mappings.
    • Extend Standard Definition: Create a custom definition by extending a standard definition to inherit its standard components such as nodes, attributes, and mappings. You can’t modify the inherited standard components. However, you can add new nodes and attributes to the extended standard definitions. Extended definitions appear under the Custom Definitions tab. When the Industry Clouds update a standard definition for a new feature, the inherited standard components of the corresponding extended definition also get those updates automatically. If there's a failure with automatic updates, you also have the option to manually update your extended components.
    • Clone a Definition: You can also clone an existing standard or custom definition and modify it. The cloned definition appears under the Custom Definitions tab.

Nodes

Nodes are containers for attributes that are mapped to objects and each node can contain multiple attributes. A context structure is a placeholder for digital data in a hierarchical format. Use nodes to define the context structure. Then, use the structure to pass the correct set of information during each step of the process.

Here’s the Structure tab showing a list of nodes.

The Structure tab with the node structure highlighted.

Attributes

Attributes are containers for data. Each attribute is mapped to a specific field of an object. Here’s the Structure tab showing the nodes and attributes of the SalesTransactionInherited node.

The Structure tab showing the list of attributes associated with the SalesTransactionInherited node.

Context Tags

Tags are easy-to-use aliases for nodes and attributes in the context structure. The consuming application uses tags to directly query data from the context definition. Here’s the Context Tags tab showing the SalesTransaction node tag and attribute tags for each attribute.

The Context Tags tab showing the nodes and attributes of the SalesTransactionInherited node, and the associated context tags.

Context Mapping

Context Mapping maps the nodes and attributes to an input data source. Mapping loads data into a context instance at run time. You use this data to complete your application’s processes. Here’s the Context Mapping page showing the mapping between nodes and objects, and attributes and fields.

The Context Mapping page showing the mapping between nodes and objects, and attributes and fields.

Map the nodes to the Salesforce objects or Data Model Objects (DMOs) and the attributes to the fields within the objects.

Mark as Transposable

If you mark a node as transposable, it stores the data in its attributes as key-value pairs. Consuming applications decide how they want to transpose the data. The key attribute holds the key, while the corresponding attribute marked as value stores the associated value. You can only mark the child nodes as transposable. This feature is available only in custom definitions or custom nodes. Here’s the Add Nodes window showing the nodes and the Mark as Transposable option.

The Add Nodes page showing the Mark as Transposable option for the Contact node.

For example, if you want to determine a product’s price based on one of its attributes, such as the color of the product, create a node called ProductAttribute and mark it as transposable. Under the ProductAttribute node, you can add two attributes: Attribute Name, which is the key, and Attribute Value, which is the value. You can store Color as the Attribute Name, and Blue as the Attribute Value.

Next, learn how to configure Context Service at design time and process it at run time.

Context Service Design-Time Process

In Context Service design-time process, you set up the Context Service metadata and structure as per your data access requirement. Here’s how the Context Service design time process looks like.

The Context Service design-time process.

Use these high-level steps to configure Context Service.

  1. First, create a context definition. The definition sources and serves data in an abstract manner in various digital processes.
  2. Next, create a context structure where you add nodes, attributes, and associated data types.
  3. Next, create and associate context tags to each node and attribute.
  4. Finally, create a context mapping.

Now, your applications are ready to fetch data using the context definitions and mappings you created.

Context Service Run-Time Process

Use Context Service run-time process to call the Context Service APIs from your applications. You can build, query, update, and persist context data according to the context definitions and mappings defined during design time.

Here’s an overview of the Context Service run-time process workflow.

The Context Service run-time process.

After you finish setting up the context definition and mapping as part of the design-time process, digital processes can invoke the Context Service Build APIs to create a run-time context instance. This instance extracts data from different objects as defined in the context mappings. The context instance is kept in temporary transient data stores for fast data access. Processes can interact with this instance efficiently instead of always accessing the database. When the digital processes consume and update the context instance, you can persist the modified instance to objects. Optionally, you can use one mapping to read the data from objects and a different mapping to write data to different objects.

Wrap Up

Congratulations! In this module, you learned what Context Service is and why businesses need it. You got to know the benefits and capabilities of Context Service. You also explored the Context Service design-time and run-time processes.

Now that you know the basics of Context Service and its advantages, use this knowledge to improve the data accessing and integration experience for your users.

Resources

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios