Skip to main content
The Trailblazer Community will be undergoing scheduled maintenance from 8:40 PM PDT on Wednesday, September 30 to 3:00 AM PDT on Thursday, October 1, 2026. During this window, the site will be unavailable.

Get to Know Business Rules Engine and Context Service

Learning Objectives

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

  • Describe Business Rules Engine and Context Service.
  • Explain how Business Rules Engine and Context service work together for business rule automation.

Before You Start

Before you start this module, consider completing the following recommended content.

Business Rules Engine and Context Service at a Glance

Business Rules Engine is a no-code product suite for automating complex decision-making such as pricing, eligibility, and scoring that goes beyond standard Salesforce logic. It generates predictable outputs based on business rules.

Business Rules Engine consists of these key components.

  • Expression Sets are sequential, multi-step declarative configurations of logical rules to automate business decisions.
  • Decision Matrices are standard lookup tables for matching inputs to outputs.
  • Decision Tables are advanced lookups that read rules directly from Salesforce records for high-volume decision management.

Context Service is a data abstraction layer that simplifies data retrieval. It fetches and structures raw Salesforce data into a standard format for features such as Business Rules Engine and Revenue Cloud Pricing to consume without querying the database directly.

Context Service consists of these key features.

  • Context Definitions represent the blueprint defining the data structure or schema.
  • Mappings are instructions linking the Context Definitions to Salesforce objects.
  • Tags are labels that enable rules to reference data without using field API names.

In this badge, you learn how to use the combination of Business Rules Engine and Context Service to provide a powerful, scalable solution for complex business rule automation.

First, explore the features of these products by using an example.

How Business Rules Engine and Context Service Work Together

Context Service handles data requirements, such as fetching, structuring, and caching data. Business Rules Engine then handles the logic requirements, such as creating and evaluating business rules. By combining these capabilities, business users can build advanced decision rules for complex, multi-level data without writing code—all while ensuring optimal efficiency right out of the box.

Here’s a high-level workflow of how both components work together.

  1. The Trigger: A process, such as Salesforce Flow, Expression Set, or API call, initiates a request.
  1. The Context Service Layer: The request in turn calls Context Service. Context Service uses a Context Definition to determine what data is needed and uses mappings to locate it in Salesforce objects. The Context Definition automatically queries and hydrates this data into a standardized hierarchical structure.
  1. The Handover: When creating an expression set in Business Rules Engine, you select the Context Definition. The tagged data from the Context Definition become available as resources in your expression set. The expression set does not query Salesforce. It simply receives the data prepared by Context Service.
  1. The Logic Layer: The expression set in Business Rules Engine executes the logic, such as lookups and calculations. It references data variables by using flexible Tags from Context Service rather than rigid Salesforce API names.
  1. The Result: The expression set sends the final output to Context Service, which then sends it back to the triggering process to be saved or displayed.

This process provides these key benefits.

  • Hierarchical Data Management: Without Context Service, your rules reference specific field API names. If you change your data model or migrate data to a new object, a rewrite of every rule is required. With Context Service, your rules reference flexible Tags. If the underlying data moves from a custom object to a standard object, you only update the mapping in Context Service. The business rule logic remains untouched.
  • Improved Performance: Context Service pre-loads and caches all required data, which minimizes repeated database queries and handles large datasets efficiently.
  • Simplified Rule Authoring for Business Users: Business users can modify rules without the expertise of data relationships. Context Service flattens complex relationships. For example, a user simply selects a MailingCountry tag without knowing that the data actually comes from Account.Contact.MailingCountry. Here, Mailing Country is a field in the Contact relative object, which is in the Account object.
  • Reusability: Use a single Context Definition in multiple processes and channels such as web portals, mobile apps, or internal systems. The same data structure supports different business processes, such as pricing, eligibility checks, and qualification. For example, both a Pricing process and a Qualification process can use the same order context.
  • Efficient Data Handling: Context Service eliminates the need to pass massive JSON payloads by replacing them with a simple Context ID pointer. Instead of carrying all the data, the Rules Engine uses the Context ID to pull only the specific attributes required for evaluation. This streamlined approach significantly reduces CPU usage and prevents exceeding Salesforce memory limits.

Now that you’re familiar with how Business Rules Engine and Context Service work together, explore the scenario that you use in this badge.

Opportunity Discount and Compliance Status Automation

Imagine that your sales team wants to provide a discount for sales deals based on two factors: Account Rating and Opportunity Amount. Additionally, they want to implement compliance by identifying and flagging large discounts as High Risk. They also want to automate this process so that the sales team members don’t have to manually enter these details for any prospect.

As a Salesforce admin, your job is to configure this requirement by using Business Rules Engine and Context Service components. To achieve this, you apply three layers of logic to every opportunity.

Step Sequence

Calculation

Logic

Requirement

1

Base Discount

Matrix

The system looks up a base discount percentage determined by the Account_Rating__c field, which has values of Hot, Warm, or Cold.

  • Hot: 10%
  • Warm: 5%
  • Cold: 0%

2

Sales Discount

Conditional

The system evaluates the value of the deal from the Opportunity Amount. If the amount exceeds $100,000, an additional 5% is added to the base discount. If it’s below the $100,000 threshold, no discount is applied.

3

Compliance Check

Risk

Finally, the system sums the Base Discount and the Sales Discount to create a final discount. It then checks this total against a risk threshold with these criteria.

  • If the Total Discount is greater than or equal to 15%, the status is flagged as High Risk.
  • If the Total Discount is less than 15%, the status is marked as Approved.

Here are the components that you configure in this badge.

  • Context Definition: To hydrate data from the Opportunity object and fields such as Account Rating, Calculated_Discount__c, and Risk_Status__c
  • Decision Table: To calculate the base discount based on account rating
  • Expression Set: To calculate the total discount and risk status based on account rating and amount for an opportunity
  • Salesforce Flow: To execute the entire logic automatically whenever you create or update an opportunity

You start creating these components in the next unit.

What’s Next?

In this unit, you learned about Business Rules Engine and Context Service components and how they work together. You also explored the example scenario that you configure in this badge.

In the next unit, you sign up for a special Developer Edition org to complete the scenario. You then create a context definition to define a context structure that includes nodes, attributes, and tags. You also create a context mapping to map the nodes with objects and attributes with fields.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback