subscribe our youtube channel popup

Guidelines to setup Business Rules using Decision Tables

Business Rules Engine is a suite of services, components, and objects that apply advanced logic and automate complex decision-making. It is a powerful system which allows non technical users and developers to build scalable lookups and more complex calculations (no-code/low code) and automate business processes.

Business Rules using DecisionTables

Business Rules Engine components are available for integration as part of Flows and Omnistudio. Also, you can use Connect APIs to integrate Business Rules Engine with any workflow created using custom or third-party tools. The workflow that you use to gather inputs passes the inputs to Business Rules Engine, which then returns the outcome to the workflow that called the Business Rules Engine component.

In this article, we will understand Business Rules Engine and its components. Also we will see how to setup business rules using decision table.

Components

The engine contains three major components: expression sets, decision matrices, and decision tables. Each component offers different core functions, and they work together productively and seamlessly.

EXPRESSION SET

An expression set is the calculation engine of business rules, you can create series of rules with expression set elements. Each element in a set forms a logical step that runs sequentially. Expression sets evaluates conditions, perform mathematical operations, look up decision tables and matrices, and perform multiple transformations simultaneously. Expression sets accept JSON input from and return JSON output to the digital processes that call the sets.
You can add expression sets to workflows created with Flow, Omnistudio, and third-party tools.

DECISION MATRIX

A decision matrix matches input values to a table row and returns the output values of the row.
Expression sets and various digital procedures can call decision matrices. Decision matrices accept JSON input from, and return JSON output to the digital processes that call the matrices. Decision matrices are useful for implementing complex rules
in a systematic, readable manner.

DECISION TABLE


Decision tables are complex lookup tables that read business rules with multiple inputs and return multiple outputs for records in your Salesforce org or for the values that you specify. Rules are records in a standard object, a custom object, or a custom
metadata type.

Build business rules using decision table

Sign up for a free Developer Edition org with Business Rules Engine. This org will have fully enabled set of BRE licenses. Once you have logged in, open the App Launcher, then open the Business Rules Engine app. Now that you’re set up, let’s walk through steps for creating a decision table to get Car rental fees for given
state and test it using REST-Api. Let’s get building!

CREATE NEW CUSTOM OBJECT

Create new custom object ‘Car Rental Fees’ for the decision table. Fields of this object would be used as input and output fields for the rules engine. Here we are building business rules engine to calculate Car rental fees for input States, for that purposed we will creating following custom fields:

Car Type – Text(255)
Rental States- Multi Select Picklist
Daily Fees – Number(8, 0)
Vehicle Class – Text(100)

CREATE NEW DECISION TABLE


Navigate to Business Rules Engine console app from App Launcher, click on the dropdown select Lookup Tables. Click on the
New button on the top-right corner of the page. Two types of lookup tables are available.
-Decision Matrix – An exact-match based lookup that returns a single output.
-Decision Table – A custom-logic based lookup that returns one or more output sets

For this use-case we are selecting Decision table as multiple fees can be proposed to user depending on the state.

Enter basic details for the decision table as per the image:

Name – Car Rental Fees Rules
Description – Business Rules for car rental fees
Application Usage – Default. (Note: Multiple Application Usage types are available in system like Record Alert, Product Qualification, Financial Service Cloud etc. We will select default for the Integration usage).
Decision table type – Advanced. (Note: Advanced decision tables support simple rules that use a combination of AND and OR conditions, whereas Standard decision tables support complex rules that use only OR conditions.)

Click on Save & Next button.

Select source object as ‘Car Rental Fees’, keep related objects as blank.

Select following Conditions and Results for the Car rental fees rules.

Condition fields:
Vehicle_Class__c => ‘Equals’ Operator
Rental_State__c => ‘Exists In’ operator
Result fields:
Daily_Fees__c
Car_Type__c

Click on Save & Next
Set following values for Behaviour section
Filter Result By – Output Order
Sort By – Daily_Fees__c

Click Save & Next, then preview selected rules and click on Finish.

After page is reloaded, click on View Object Record Page to setup data for rules engine as per business requirements.

Now your business rules are setup in decision table. Click on Activate button to activate the rules.
Note: This decision table uses multi-select picklist field, hence it can be integrated through Connect APIs only.

TEST DECISION TABLE FROM REST-API

The decision table rules can be tested using POST REST-API using given url.
https://{SandboxName}.sandbox.my.salesforce.com/services/data/v{versionnumber}/connect/decision-table/{table id}
Sample request:

Sample Response:

Benefits of Business Rules Engine

Business Rules Engine can be used in different industries like Financial services, Healthcare, Insurance, Communication where many input or output variables are required and many permutations and combinations are involved. Here are major
benefits of rules engine.

  • Intuitive – Business users can design via visual no-code builder
  • Agile – Business users can easily maintain & extend decisions
  • Easy to Integrate – Rules can be embed in any digital interaction or process
  • Rich Functionality – Engine supports multiple Conditions, Calculations, Lookup Tables, Sub Rules
  • Transparent – Use decision explainer to audit and describe rules
  • Highly Performant – This is highly scalable engine designed to meet B2C needs

Pradnya Desai
Pradnya Desai

Senior Technical Architect specializing in Analysis, Design, Development of cross cloud solutions using Salesforce platform - Sales Cloud, Service Cloud, Experience Cloud. Expert in implementation of REST Services, Middleware Applications, OSB - SOA and related technologies. Experience in Einstein Bots, Digital Engagement, Amazon Connect, Omni Channel, Omni Studio, Financial Service Cloud. I have 22+ years of experience in application development and 8+ years of experience in the Salesforce ecosystem.
https://www.linkedin.com/in/pradnya-desai-b9a51619/

Articles: 1

Leave a Reply

Your email address will not be published. Required fields are marked *