Customizing Salesforce to Avoid Duplicate Contact Creation and Automate Email Sending

15 Apr, 2021 | 5 minutes read

As a Customer Relationship Management Service, a Salesforce developer provides a wide range of applications focused on customer service, marketing automation, analytics, and application development. As part of the system, Salesforce has contacts and accounts as standard objects. If we want to define contacts and accounts, contacts are used for storing information about the people that you are doing business with. 

Accounts are companies that you’re doing business with, and contacts are the people who work for them. Objects can be related to other objects, no matter standard or custom. Contacts are usually related to accounts, but also, they can be related to other objects in Salesforce. Contacts in Salesforce can be created manually, or automatically through mass import. Sometimes, duplicate contact creation can happen, which might cause troubles in the sales process.

How can you prevent this from happening and how can you automate email sending based on pre-defined criteria? In the following blog post, we will focus on a use case of creating contacts and automating sending emails. In our case, contacts are already inserted through a joint solution with MuleSoft technology and Robotic Process Automation to avoid repetitive tasks and to enhance the process of digital transformation. In the scenario, a MuleSoft application triggers the configured robot to load and extract Salesforce Contacts’ data and sends them to an application flow, for the purpose of cleaning up the data and transformation to the Salesforce Contact Objects in a suitable format for insertion, directly in Salesforce. Let’s explore the automation and rules that can be created for better use of contacts in Salesforce.

The contacts below are the contacts that are imported from MuleSoft team into Salesforce.

The contacts which are already imported with MuleSoft as shown below, are preprocessed, without duplicate data. But in Salesforce, as a major CRM platform, the sources are many and diverse, so appropriate prevention of creating duplicates on a platform level is a must.

The contacts imported with MuleSoft

The practice shows that after importing contacts, some contacts can be added 2 or more times, and be displayed as a duplicated contact. Preventing the creation of duplicate contacts is very important. There are companies that work with over 1000 contacts, and they can’t lose time to manually check duplicated contacts when a new contact is created. The worst thing that can happen when you are working with CRM is that your data is in bad shape. This is why you need to ensure that there isn’t duplicated information. The best solution, in this case, is creating duplicate rules with matching rules.  

Duplication rules determine if you can create duplicate records in Salesforce. In other words, it’s a rule that tells what to do when you are trying to create a record that already exists in Salesforce. Duplication rules are a great way to keep your data clean. In order to be able to create a duplicate rule, you will need to have appropriate user permissions.

We will use an example from the imported contacts, attached in the screenshot above (Jane Grey). We are going to create a rule that will prevent creating another contact with the same phone number as Jane Grey.

First, we are going to create an active matching rule for the contact object. We will add a criterion if the phone number is matching to prevent the creation of the records.

matching rule detail

After we have created the matching rule, we will create a duplicate rule,  which will be related to the matching rule that was created before. A duplicate rule determines what happens when a matching rule identifies duplicate contacts during creation.

After matching rules identify potential duplicates, the duplicate rule determines what to do with them. You can choose to block the process of creation or allow it by displaying a warning message.

duplicate rule detail

Once we have created the rules, we will test it by creating a new contact  (with the same phone number as Jane Grey). If the rule works as it should, we will not be allowed to create a new contact (because we blocked the process of creating duplicate records).

new contact table

As you can see from the picture above we are not allowed to create a new contact with the same phone number. That means the rule works as it is supposed to work.

With only a few clicks, we can prevent the creation of duplicate records.  

The imported contacts are pre-defined with a few fields – Name, Account Name, Title, Phone, and Email. These are all standard fields. Salesforce allows the creation of custom fields. So, we will create a custom picklist field – Department with more values (IT, Banking, Financial, Accountant, Audit..)

We will create automation through workflow rule using the new custom field:

  • In cases when the Department is equal to IT, send an email reporting to the management.

Workflows in Salesforce are a fantastic way to automate certain business processes. You can create a rule, and based on certain predefined criteria Salesforce can do a number of things, like send an email, create a task, or update a field.

In this example, we decided to use automation for sending an email notification to the management.

To create a workflow rule, you need 2 things:

  • Criteria, when the rule should run (in this case, when Department = IT)
  • Actions that execute when a record matches the criteria (in this case, an email alert)

Before creating workflow automation, we will create an HTML email template (the template that will be used for sending messages to the management department).

Having a consistent look at the messages makes correspondence more professional. Configurable template and letterhead that all team members can use for their day-to-day email needs, make work easier.

email tamplate

In order to use an HTML template, we need to create a letterhead first.  We will use classic letterheads from the setup, and we will create a new one. There is a possibility for editing and customizing header and footer properties, colors, adding logos, etc. We will add the ⋮IWConnect logo, and customize the color to match the logo’s colors.

logo of IWConnect

After creating the letterhead, we will create an HTML email template using the letterhead that we have created.

In the email template, we will choose a formal letter, and we will write the letter using merge field values.

letter using merge field values

After that, we will test the template by using a contact (Andy Young) and an account (Dickenson plc).

preview template - google chrome

Once we have received an email confirmation that everything is set up correctly, we will create an automation through workflow rule by using the template that we have created.

We added rule criteria, when Departments = IT, send an email alert to saradimeska.123@gmail.com.

rule criteria
Edit email alert

After creating the workflow, we will edit the contact “Arthur Fisher”, and change Departments to IT.

contact detail fields

After changing Departments to IT, we will receive an email with the template that we have created before.

new it - contact field

We received a notification that there is a new contact created in Salesforce, where the Department is IT.

Summary

Prevention of creating duplicates and automation through workflow rules are really important tools that can be used for any record in Salesforce. In our case, we used these rules on contact objects. If you are wondering how they can help your business, the answer is easy. These tools eliminate any manual work related to checking duplicates, and on top of it include sending notifying emails. Thus, you save time, and increase productivity, and operational efficiency.