Loading
Salesforce now sends email only from verified domains. Read More
Business Rules Engine
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Best Practices for Executing Expression Set Rules on Large Datasets by using Salesforce Flow

          Best Practices for Executing Expression Set Rules on Large Datasets by using Salesforce Flow

          Business scenarios can involve running rules on thousands or even millions of input records to get the results you need. Business Rules Engine gives you multiple options for bulk processing rules on large datasets, according to your specific requirements. You can run business rules on large datasets in a single call or in batches.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise, Unlimited, and Developer Editions for Industries clouds that have Business Rules Engine and Context Service enabled
          User Permissions Needed
          To create, update, and delete expression sets Rules Engine Designer
          To run expression sets in Business Rules Engine Rules Engine Runtime
          To create a flow Manage Flow
          To load, view, edit, and delete context definitions Context Service Admin

          Review the options to bulk process rules on large datasets with Salesforce Flow and choose the option that best suits your business needs.

          • Option 1: Use Standard Expression Sets and Batch Management
            To run rules on thousands or millions of input records in batches, use standard expression sets and batch management to process the rules. Create your rules in expression sets and batch job definitions in Batch Management. Use the batch job definitions to process your rules in batches. Finally, invoke the expression set and batch job definition in Salesforce Flow to execute your rules on input records.
          • Option 2: Use Context Service and Expression Sets
            If you want to run rules on thousands of records in a single call and need faster data access for your business processes, use Context Service to serve your data request. Use expression set to create your rule and fetch the data from objects through Context Service. Finally, invoke the expression set with context data in Salesforce Flow to execute your rules on the input data. You can get the results in real time by using this option.

          Option 1: Use Standard Expression Sets and Batch Management

          To run rules on thousands or millions of input records in batches, use standard expression sets and batch management to process the rules. Create your rules in expression sets and batch job definitions in Batch Management. Use the batch job definitions to process your rules in batches. Finally, invoke the expression set and batch job definition in Salesforce Flow to execute your rules on input records.

          Make sure you limit the batch size according to the Business Rules Engine guardrail limits. See Business Rules Engine Default Limits.

          Here’s the overview of the process on how to run rules on large datasets by using expression sets and Batch Management in Salesforce Flow.

          High-level overview of processing business rules on large datasets with expression sets and batch management in Salesforce Flow

          Here's how you configure the process.

          1. Create an Expression Set: In Business Rules Engine, create an expression set to define your business rule, configure the expression set based on your requirement, and then activate it.
          2. Create an Autolaunched Flow: Create a flow to orchestrate your process and make sure you use the Autolaunched Flow type so that the flow is available in Batch Management.
          3. Invoke Expression Set: In Flow Builder, add an Action element. Search for the Expression Set action and add it to your flow. The Flow uses this action to invoke the expression set. Configure the inputs for the Expression Set action and make sure that all the parameters are correctly mapped in the action configuration. Activate the flow.
          4. Create a Batch Job Definition: In Batch Management, create a batch job definition by defining the process type as Flow and the execution process as Autolaunched Flow. Activate the definition.
          5. Create a Scheduled Flow: Create a Schedule-Triggered Flow to execute the batch job at a certain date and time based on your requirement.
          6. Invoke Batch Job Definition: Add an Action element in the Schedule-Triggered Flow and search for Batch Job in the Action window. Select your batch job definition and configure the details. Activate and run the Flow.
          7. Monitor Workflow Services: You can monitor the status of each batch job run in the Monitor Workflow Services section.
          Example
          Example

          An online retail company uses Salesforce Loyalty Cloud to determine the loyalty points each customer earns based on their purchases and tier levels. The company uses complex loyalty rules defined in Business Rules Engine to calculate the points. The company processes 2 million daily transactions in bulk by using Batch Management. Salesforce Flow automates the points determination process by running a scheduled batch at regular intervals. Business Rules Engine and Batch Management together make sure accurate and efficient points allocation across large volumes of transactions.

          Option 2: Use Context Service and Expression Sets

          If you want to run rules on thousands of records in a single call and need faster data access for your business processes, use Context Service to serve your data request. Use expression set to create your rule and fetch the data from objects through Context Service. Finally, invoke the expression set with context data in Salesforce Flow to execute your rules on the input data. You can get the results in real time by using this option.

          Here’s the overview of the process on how to run rules on large datasets by using expression sets and Context Service in Salesforce Flow.

          High-level overview of processing business rules on large datasets with expression set and context service in Salesforce Flow

          Here's how you configure the process.

          1. Create a Context Definition: Create a context definition in Context Service. Add nodes and attributes with the relevant data types. Add context tags to each node and attribute. Map the nodes with objects and attributes with fields. Activate the context definition.
          2. Create an Expression Set: Create an expression set and select the context definition. Use list group and list filter elements to call the data from your object. List filters use the context mapping defined in the context definition to fetch the requested object data. Use the expression set to configure your business rule and make sure to activate it.
          3. Create a Flow: Create a Screen Flow to configure and execute your process. You can also use a Schedule-Triggered Flow to execute your process at a certain date and time as per your requirement.
          4. Invoke Context Definition: Add an Action element in Flow Builder. Under Search Action, search for the Build Context action and add it to flow. This action creates a context instance and fetches the context definition details during runtime. In the Setup Input Values section, add the context definition ID in the Context Definition field. You can also add Context Data, Context Mapping, and Tagged Data details as per your requirement.
          5. Invoke Expression Set: In Flow Builder, add an Action element. Search for the Expression Set action and add it to your flow. The Flow uses this action to invoke the Expression Set. Configure the inputs for the Expression Set action and make sure that all the parameters are correctly mapped in the action configuration. Activate and run the flow.
            Context Service also has a guardrail limit for the maximum number of records on which you can run rules in a single call. See Context Service Limits.
          Example
          Example

          A government entity wants to verify if a citizen is eligible for welfare benefits based on multiple factors such as income, family size, age, disability status, and employment status. Context Service can pull the data for each employee in real time from citizen records and Business Rules Engine can apply rules to determine eligibility.

           
          Loading
          Salesforce Help | Article