Salesforce as a CRM tool holds a lot of customer data, with the data increasing with each passing day. Every business has many sales executives using Salesforce. As a result, there are high chances of data duplication.

Imagine a scenario where one of your sales executives is working with a lead and converts it into an account. Another sales executive happens to manually enter the data for the same lead and starts the sales journey for it. It would create a mess, and the experts offering Salesforce architect as a service know that.

Therefore, it is important to have proper duplicate and matching rules in place to avoid duplication of records knowingly or unknowingly.

Salesforce provides duplicate rules and matching rules that can be created and edited as per business requirements to ensure no duplication of data. A Salesforce admin must configure these rules as per business requirements.

Let us discuss matching and duplicate rules provided by Salesforce with an example.

In the Homely Food app we created, there are chances of duplication of employee records. Let us see the necessary steps we can take to avoid duplication of the employee record.

First, we will create a matching rule and then a duplicate rule to avoid duplication.

What is a Matching rule in Salesforce?

The matching rule is a rule in Salesforce, that defines the basis on which a record should be identified as a duplicate record. When a record is fed to Salesforce, it first checks the matching rule. If the record matches an existing record as defined in the matching rule, Salesforce considers it as a duplicate record.

In the case of employee records, we want Salesforce to consider a record as duplicate if the phone number and email address of the record created is the same as an earlier record. Let us create the matching rule.

How to create a matching rule in Salesforce?

  1. Go to setup
  2. Search for the matching rule in the quick find. Click on matching rules.

You will see there are already matching rules in place for custom objects account, contact, and lead. We can create new matching rules or edit existing rules as per our requirements. 

  1. Next, click on New Rule. 
  2. Select the object to create a matching rule. Here, we will choose an employee object.
  1. Fill in the details
  • Rule details

Rule name and unique name– Name your rule. Here, we will name it the employee matching rule.

Description– Add a description. Here, we will add- To match employees based on their phone number and email address.

  • Matching criteria

Based on matching criteria, the record will be matched with a previous record.

Field- add the field you want to compare. We will select a phone number and email address.

Matching method– Select exactly. Salesforce will match a record only if the entire record is the same.

Match Blank fields- If you check this box, if fields are left blank, it will be considered as a match with another record whose field is blank. We will leave it unchecked.

  1. Click on Save.
  2. Our matching rule is created.

The matching rule will be considered only if active. Hence, you need to activate the rule. Click on the activate button to make the rule active.

After creating a matching rule, we will now create the duplicate rule.

What is the duplicate rule in Salesforce?

The duplicate rule is a rule in Salesforce that defines the action path after a record is matched with an existing record. After a record is identified as a duplicate based on the matching rule, the duplicate rule is fired by Salesforce to take further action. Records can be either allowed to save or blocked to create based on the defined duplicate rule.

In the case of employee records, we do not want to allow the employee with the same phone number and email address. We have to define the duplicate rule for this to happen.

How to create duplicate rules in Salesforce?

  1. Go to setup
  2. Search for duplicate rules in Quick Find. Click on duplicate rules.

You will see duplicate rules created by default for standard objects account, contact, and lead. We can create a new duplicate rule as per our requirement.

  1. Click on the new rule button and select the employee from the drop-down menu.
  1. Fill in the details
  • Rule details

Rule name- Name your rule. Here, we will name it the employee duplication rule.

Description- Add a description. We will describe the rule as Avoid creating duplicate employee records.

Record level Security– It defines the records, and a matching rule can be compared based on the organization’s sharing rules. You can select between enforcing sharing rules and bypassing sharing rules. 

  • Enforce sharing rules are user-specific. It will match the record only with the records a user has access to. If the user does not have access to a record and enters the same record details, his record will not be considered a duplicate. 
  • Bypass sharing rules are not user-specific. It will match the record with all the records in the database. If the user does not have access to a record and enters the same record details, the record will be considered a duplicate.

We will select bypass sharing rules for our employee record, as we do not want the employee record to be duplicated.

  • Actions

It will specify what happens when a user tries to save a duplicate record.

Action on create– You can select either allow or block. Allow will allow the user to save the duplicate record. You can check the boxes alert and report if you select allow. It will give an alert message to the user before saving the record. The Block will prevent the user from saving the duplicate record.

Alert Message Error message

We will select block as we do not want a duplicate employee record.

Action on edit- it will be applicable when a user tries to edit an existing record. You can select either allow or block similar to the action on create.

Alert text– Add a text you want to send as an alert message to the user.

  • Matching rules

These define how duplicate records are identified. 

Compare employees with– select the object you want to match the object with. Here, we will select the employee.

Matching rule– As we have created a matching rule beforehand, we can select that. If a matching rule is not created, you can also create it from here. We will select the employee matching rule.

Salesforce also provides the option of adding more than one matching rule by clicking on the Add rule button.

  • Conditions

This is an optional section. It allows you to specify conditions a record should meet for the matching rule to apply. For example, If we want an employee record to be matched only if the employee is from New York City. Then we can add the condition here. Salesforce will then fire the matching rule only if New York City is entered otherwise not.

We will leave this section blank.

  1. Click on Save.
  2. The duplicate rule is created

The duplicate rule will be considered only if active. Hence, you need to activate the rule. Click on the activate button to make the rule active.

The duplicate rule and matching rule are now active. Let us test them.

  1. Go to the Homely food app and click on the employee’s tab.
  2. Click on the new button and fill in the details.
  1. Now create another employee with the same details except the name.
  1. Salesforce will shoot an error message.
  1. You can click on the view duplicates and see all the records with the same details.
  1. You will have to enter other details to save the employee record.
  2. If we had selected allow in the action to create option, Salesforce would have shown an alert message, and we could have saved the duplicate record.

Based on the requirement of the business, a Salesforce admin can configure the duplicate rule to allow or block duplicate record creation.

Cases where a duplicate rule is not applicable

When the records have to be matched with records in an external app apart from Salesforce, a duplicate rule cannot be applied. In such cases, you will have to use the apex and avoid duplication. The duplicate rule applies to the data and records in Salesforce only, as per the expertise of the Salesforce architect as a service provider.

By delipat

Leave a Reply

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