Custom Domain Matching for Salesforce Lead Routing to Existing Accounts: Part One

This is the first installment in a two-part post, providing a step by step guide for a custom lead routing solution using Salesforce Flow. In part one, I look at configurations on the lead object, contact object, creating an email template and email alert. In part two, I detail a comprehensive Salesforce Flow.

Lead routing is an important function to any organization selling products or services. In many cases, criteria like geographic location or product interest drive assignment rules.

Salesforce offers Lead Assignment Rules for this very purpose. You can define criteria or a set of rules to determine who should be assigned the record. For most use cases, this feature is more than sufficient.

But what if you want to match criteria dynamically? For instance, if you wanted to assign a lead to the Salesforce user who already owns an account, lead or contact with same email domain? Lead Assignment Rules are insufficient for this type of logic.

There are pre-built solutions that you can download from the AppExchange, but I haven’t done that research. The purpose of this post is to provide step-by-step instructions for a solution you can build yourself.

Before you begin…

You’ll need to be a Salesforce administrator with the ability to…

  • create lead and contact fields.
  • create an email template.
  • create a Flow.

If you’re not comfortable with these tasks, I recommend sharing this post with someone within your organization who is. Building Flows can be intimidating, but I will detail every step explicitly.

Creating Lead and Contact fields

Before getting into the Flow, we need to create a couple fields on the lead and contact objects.

Domain – Create a text formula field on both the lead and contact, using the following formula:

RIGHT(Email, LEN(Email) - FIND('@', Email))

This will pull the entire string of text after the “@” symbol in the records Email field. We will use these fields to find other records with the same email domain.

OwnerActive – Create a checkbox formula field on both the lead and contact, using the following formula:

Owner:User.IsActive

This will pull in a true or false value depending on the status of the related user record owner. We will use these fields to insure that the record owner is actually still active within the company. Oftentimes organizations won’t reassign records and we don’t want to assign new records to inactive users.

Creating an Email Template and Setting up an Email Alert

This is not a required step, however, I would recommend using an email notification for a few reasons.

Depending on the Flow “start” criteria, you may be considering leads with existing record owners. For instance, in the example I’m sharing, the Flow is only looking at lead records created by the B2BMA Integration User (created from Pardot). In order to be pushed into Salesforce from Pardot, prospects need a record owner (user or queue).

Before reassigning the record, especially if multiple Salesforce users own records with the same domain, it makes sense to send the Salesforce admin an email notifying them that there may be a potential matched account and related record owner(s) that would apply.

If your Flow “start” criteria is looking at all new lead records without an owner, then it may make sense to immediately assign the record.

Email Template – You’ll need to create a Classic Email Template in Salesforce. Make the message say whatever makes sense. In my example, I included a short message that a new lead has been created that needs to be assigned. I provided the lead name, company and a link to the record:

Email Alert – In conjunction with the email template, you’ll also need to create an email alert. Select the template you just created, select that this is for the Lead object, enter a from address and select any recipients who should see the email notification:

Next, we’re ready to start building out our flow. Stay tuned for part two by following me on LinkedIn.