Best Match Account Functionality with Fuzzy Logic
IN THIS ARTICLE
Introduction to Fuzzy logic
Fuzzy logic is a way to model logical reasoning where the truth of a statement is not a binary true or false, but rather it is with the degree of truth that ranges from 0 (false) to 1 (true).
When there is uncertainty in data and the search criteria, the Fuzzy logic option helps to filter the available best match account, as it can incorporate all intermediate values between True and False. (Fuzzy Matching- Approximate String Matching)
Salesforce Matching methods
Source Courtesy: https://www.salesforceben.com/what-are-fuzzy-matches-in-salesforce-deduplication/
Exact Match
For this match, as the name suggests, the fields in the two records should be the exact same. The match is either True or False
Record A | Record B | Method | Evaluation |
John Doe | John Doe | Exact | True |
Jon Doe | Jon Doe | Exact | False |
In the solutions, which have exact match with random order, the words match exactly but not in the same order.
Record A | Record B | Method | Evaluation |
John Doe | Doe John | Exact (random Order) | True |
Fuzzy Match
Record A | Record B | Method | Edit Distance | Intended meaning |
Cat | Hat | Fuzzy | 1 | Very Different |
Elephant | Elephont | Fuzzy | 1 | Same |
Shorter strings often have entirely different meanings with one or two edits. The longer the string, the less the impact of an edit on the meaning. To combat this problem, most deduplication solutions use a matching score based on multiple fields and a threshold to determine duplicate records.
Record A | Record B | Method | Edit Distance | Max Edit Distance | Score |
Cat | Hat | Fuzzy | 1 | 3 | 66.6% |
Elephant | Elephont | Fuzzy | 1 | 8 | 87.5% |
So longer the string, higher the matching score. This is the basic fuzzy logic used by Salesforce to compare two records. To know more in detail about Salesforce Fuzzy logic click here
Matching Rules and Duplicate rules
How to find Best Match Account with fuzzy logic?
BMA fuzzy logic Pre-requisites
- Create Fullcast Policy rule in Custom metadata type.
- Enable Standard Account Duplicate rule in Salesforce.
- Enable triggers in Fullcast Setting OR
- Call BMA using Process builder to fetch clean domain functionality or BMA.
If the rules don't create a single best match account, the BMA logic will select the oldest created account.
Creating Fullcast Policy Rules for Best Match Account
Fullcast policy rules are configured in the Salesforce instance.
- Log in to the Salesforce account.
- Click on the Setup and search for Custom Metadata types
- Click on Manage Records against Fullcast Policy Rules.
Click New and start creating the rules.
- Enter label name which must begin with a letter and use only alphanumeric characters and underscores. The name cannot end with an underscore or have two consecutive underscores.
- The Fullcast Policy Rules Name is automatically picked which is the unique name used by the API and managed packages.
- Pick Criteria as Fuzzy Logic and AND or OR Condition fields from the drop-down menu available.
- String field needs to be updated only if the Criteria field picked is LITERAL.
- Field 1 Object is Lead or Contact which needs to be compared with the Account.
- Field 1 is the API field of the Field 1 object which needs to be compared API field of the Account.
- Field 2 Object should always be Account which is compared with Field 1 object.
- Field 2 is the API field of Field 2 Account which is compared with the API field of the Field 1 object.
- Choose which operation to be performed from the drop-down menu for the field Operator. Use the table to pick the correct operator based on the Field type being used in Field 1 and Field 2 in the rules.
- Enter the number according to which the rule has to be executed. For example, if it has to be executed first then the order number is 1. If it has to be executed third, then the order number is 3, and likewise.
- Module name carries the name of your choice. It is an optional field.
Click Save to trigger and call the policy rule whenever necessary.
Configuring Salesforce Duplicate rules and Matching rules
- Search for Duplicate Rule in the Quick find tab in the Salesforce environment.
Select Account from the dropdown menu for which the rule has to be created. Create New Duplicate Rule by clicking the New rule tab.
Creating a New rule
- Enter the Rule Name. Description field which describes the rule is an optional field.
- Object for which the rule is created is displayed in the object field.
For Record-level security choose whether to enforce or bypass sharing rules according to the organization's policy. By enforcing sharing rules, the matching rule compares only those records to which the user has access to, whereas bypassing sharing rules compares all the records.
Set the actions which need to be performed when the user creates or edits a duplicate record. When you choose alert, provide an appropriate alert message as to why the user is not able to save the record and what's the next step.
- In the Matching Rules fields select from the drop-down menu to define how duplicate records are identified.
- Select the field with which the Accounts need to be compared with from the drop-down menu. In the below example it is compared with accounts. The Account can be compared with Lead, but the lead detail fields are mapped to the particular account detail fields in the backend and finally those mapped fields are compared. So even when you want to compare accounts to lead, it is mandatory to select Accounts as it is already mapped.
- Select the Matching rule required for comparison. In this particular example, it is the Standard Account Matching Rule.
Select the fields that need to be mapped. The below example shows the fields that are mapped in the Standard Account Matching Rule.
If there are any conditions to be met for the rule to run, those conditions need to be set in the Conditions fields which are optional.
Click Save to create the duplicate rule. The standard account duplicate rule created screen will look like the following:
The fuzzy logic rule will fetch records that are the best match for the account. This can be further filtered using the Tie-Breaker or Field- Compare
BMA version 2.166
New BMA fuzzy logic feature has been added in the package version 2.166. Currently we are considering all the duplicate accounts coming from all the active duplicate rule. This package feature enables the user to pass only particular duplicate rules name to filter the duplicate records for BMA.
- If string value is NULL - then it will pick the matched account from all the duplicate rules.
If string value is comma separated values of Duplicate Rule API name, then only matched account from those Duplicate Rules are picked.
Note
If there are any Custom Duplicate Rules Enabled and if the above mapping rules to Lead and Account gives a set of Accounts. Those Accounts are also considered for calculation of Best Match Account.
Standard Account Matching Rule
The standard account matching rule identifies duplicate accounts using match keys, a matching equation, and matching criteria. It’s activated by default. More than one rule can be added if needed. It can be removed as well if not necessary.
For accurate matches, the new or edited record must include a value in the Account Name field and either the City or the ZIP Code field.
(Account Name AND Billing Street) OR (Account Name AND City AND State) OR (Account Name AND ZIP) OR (Account Name AND Phone) OR (Website AND Phone) OR (Website AND Billing Street)
Triggering the BMA function
After setting up the rules, it is essential to trigger the process either by enabling the flags in Fullcast setting or by calling BMA in Process builder.
Enabling triggers in Fullcast Setting
- Click on the Setup and search for Custom Metadata types
- Click on Manage Records against Fullcast Setting.
- Click New and start creating the Fullcast Setting.
- Select a Label for the setting.
- Check the Account, Contact and Lead trigger flags.
- Set a number for the Error log that needs to be displayed.
Click save. When these flags are checked, the clean domain functionality will be triggered when there is a website address in the Website field. Whenever a new data is added or edited in the website field the clean domain functionality is triggered.
Configuration of Process Builder for BMA with Fuzzy logic
Setting up a process builder in Salesforce environment for each policy to trigger it when needed is necessary. Follow the below screenshot for process builder setup.
You can also refer to Configuration of Process builder in Motion policies document for detailed step-by step process.
The Best Matched Account for the Lead Account is displayed in the BMA field if there is any record found. Below is an example of Lead detail with a best matched account.
BMA with fuzzy logic cases which involve different criteria and conditions
Field setup needs to be created in Fullcast Policy setting by using the field value directly or Lead field value can be used as shown below.
Case 2: Using Picklist in Condition
Case 3: Using Number Field
Case 4: Using Date field in Condition
Condition 3: When the date value equals null, it should fetch the data correctly.