Assign a Lead in Salesforce based on existing Contact Owner

Lead Assignment Rules in Salesforce are useful, but fairly limited. For example, one of the things you can’t do is assign a new Lead to the same owner of an existing Contact in Salesforce.

Why might you want to do this? Well, let’s say your business uses Web-to-Lead functionality where customers/prospects fill in an enquiry form on the website and their enquiry automatically gets created as a new Lead in Salesforce. What happens if that customer has bought from your business before, and dealt with a specific sales person? You might want the customer’s repeat business to be automatically assigned to the same rep.

Lead Assignment Rules don’t allow this kind of Named Account/Contact assignment, even though apparently themselves operate such a named account policy in their sales organisation.

In the Salesforce Trailblazer Community, lots of people ask how to assign Leads to appropriate Account/Contact owners (as in this post), and there are a few apps in the Salesforce AppExchange that provide the functionality at a price.

Here’s a way to implement a simple version using Process Builder and Visual Workflow. It uses just four elements in a Flow which searches existing Contacts for an email address, and a simple Process that fires when a new Lead is created. This works for existing Contacts, but it would be easy to extend to existing Accounts if you need to.

Create the Flow

The Flow we are going to create uses just four elements: an sObject Variable that contains the Lead that gets passed in from Process Builder, a Record Lookup to search existing Contacts for the Lead’s email address, a Variable to store the found Contact’s OwnerID, and a Record Update to save the Contact’s OwnerID to the Lead.

In this blog post I’ve name the Flow ‘Search Contacts for Email Address’.


Use the Resources Tab in Flow Designer to create an sObject Variable. This will be used by Process Builder to pass the Lead record to the Flow when a new Lead is created.


Use the Resource Tab in Flow Designer to create a Variable. This will be used by the flow to store the OwnerID from an existing Contact.


From the Palette Tab in Flow Designer, drag a new Record Lookup element onto the Canvas. This will be used to search for any existing Contact that has the same email address as the new Lead, and obtain the Contact’s Owner ID. This Element needs to be set as the Start Element in the Flow.


From the Palette Tab in Flow Designer, drag a new Record Update element onto the Canvas. This will be used to save the Contact Owner ID back to the new Lead record.


That’s it in terms of Visual Workflow configuration. Make sure you activate the new Flow so you can see it in Process Builder in the next step.

Create a Process

In Process Builder, create a new Process that starts when a record changes. In this blog post I’ve named the Process ‘Assign Lead Owner’.


Choose the Lead object as the object for which you wish to start the Process, and specify to start the Process only when a record is created.


Define criteria for a new Action Group, and set the condition so that the Action Group is only executed if the Email Address on the new Lead record is not null.


Finally, configure the Action Group to launch the Flow you created earlier in this blog post, and set the Flow sObject Variable ‘NewlyCreatedLead’ to Lead. If you correctly setup the Flow in the previous steps in this blog post (and activated it), everything should be selectable from within Process Builder.


Remember to activate the new Process.

Now, whenever a new Lead record is created in Salesforce, a check will be carried out to see if there is a matching Contact with the same email address. If there is, the new Lead will be assigned to the Owner of the existing Contact. Otherwise, the new Lead will be assigned to the user creating the Lead.

Limitations of this solution

This isn’t a perfect solution. One of the limitations is that the Owner of the original Contact could have moved on, and is no longer an Active User in Salesforce.

Another limitation is the fact that the Lead must have an email address matching an existing contact. A more flexible solution might be to attempt a match a Lead’s Email domain against the Website domain on an Account, which could enable any new Leads for an existing Account to be assigned to the Owner of the Account.

Has this helped you?

I hope this post has been useful. If it has helped you, please share the love with your Salesforce Ohana and leave a comment and/or share this post!

Salesforce Process Automation: the difference between Process Builder, Workflow, and Visual Workflow

Always use Process Builder wherever possible.


Salesforce has so many Process Automation options, it can be difficult to decide which one to use. Granted, there is lots of overlap, but there are a few fundamental differences once you get to know them. The best approach to deciding which Process Automation option to use is to ask yourself the following questions:

Do I need to interact with the user?

If the process you are automating relies on interacting with the user (e.g. to obtain input), you will have to use Visual Workflow to do this, as it is the only Process Automation option in Salesforce that supports screens. Easy decision.

Do I need to create a record (other than a Task)?

All three tools can create Tasks, but if you want to create other types of records (including Chatter posts), you will need to use Process Builder, or alternatively Visual Workflow if your process is more complex.

Do I need to delete a record?

Only Visual Workflow will allow you to delete records. No decision to be made here.

Do I need to send an outbound message to an external service?

If you are communicating with an external service (such as an API) and need to send an outbound message from Salesforce in XML format, you will have to use Workflow. None of the other Process Automation tools offer this facility without the need to write supporting Apex code.

Do I need to invoke some Apex code?

If the answer to this question is yes, you will need to use Process Builder or if your process is more complex, Visual Workflow.

The preceding five questions should be enough to put you on the right track in terms of which automation tool you will probably need. However, there are a few finer points that may sway your final decision. See this Trailhead article for some in-depth detail to help you choose.

What you can do with Process Builder

Process Builder should always be your first port of call when looking to automate processes in Salesforce. With Process Builder, you can:

  • Create records
  • Update records related to the one that triggered the process
  • Post to Chatter
  • Send Email Alerts
  • Invoke other Processes
  • Launch Flows
  • Submit records to an Approval Process
  • Call Apex code
  • Use a Quick Action

What you can do with Visual Workflow

Basically, anything you can do with Process Builder you can also do with Visual Workflow – all except invoke Processes. However, with Visual Workflow you can also:

  • Update any record (not just ones related to the record that triggered the Flow)
  • Delete records
  • Send emails (not just email alerts)

What you can do with Workflow

Workflow is a little more limited. With Workflow Actions you can:

  • Create Tasks
  • Update the record that triggered the Workflow Rule (or its parent record)
  • Launch Flows (this is coming soon – a pilot is in progress)
  • Send Email Alerts
  • Send outbound messages in XML format without using code

If you need any more information, Trailhead is your go-to place. There’s an excellent module on Process Automation that will teach you everything you need to know, in the usual fun Trailhead style. Go for it, Trailblazer!

Photo by Alex Knight on Unsplash.

Salesforce Certified Administrator Exam Tips

How to pass your Salesforce Administrator exam.


So far, I have found the Salesforce Certified Administrator exam to be one on the toughest I have ever taken. Maybe there’s something about the pressure of knowing a stranger somewhere in the world is watching you closely through your webcam while you sweat over sixty multiple-choice questions?

One thing’s for sure – you have to know Salesforce pretty well in order to get through this exam. It goes into a lot of detail and involves thinking through some tricky scenarios, so even if you’ve been working with Salesforce for a number of years, you will need to do some study and revision in order to pass.

First step: honestly assess your own ability

Your first step should be to download the study guide from the Salesforce Certification website. This contains an exam outline which breaks down the exam into sections like this one:


You should have knowledge and hands-on experience of each of the features and functions covered in each of the sections before you attempt the exam. Don’t try to fluff it, or you will end up failing and having to pay to resit. As with many things in life, preparation is absolutely key here.

Methodically work your way through this exam outline and highlight any sections you feel you may be weak in. A good approach might be to score yourself out of ten for each item, so you know where to focus your study/revision. It’s very important to be honest with yourself.

Each section is weighted according to its importance, and for the higher weighted sections you can expect correspondingly more questions in the exam. So for example, there will be more questions around Security & Access features than there are about the AppExchange.

Fill in knowledge gaps using Trailhead

So you’ve now mapped out where your strengths and weaknesses are in terms of the exam content. What’s the next step?

Trailhead is Salesforce’s very own online learning resource, and it’s fantastic. Salesforce staff use it internally, which should give you an idea of the quality of its content. On Trailhead you can search for individual topics and work your way through detailed modules which explain the concepts, give you hands-on practice, then test your knowledge as you go along.

Update: there’s now a dedicated ‘Trailmix’ for those preparing for their Certified Salesforce Administrator exam.

Mock exams and flashcards

There are many mock exams and flashcards available on sites like Quizlet and Cram. While these are good for testing yourself and gaining a bit of confidence, the quality is variable and you shouldn’t totally rely on them because they may not cover everything you need to know in order to pass the exam.

Salesforce Ben and some of the other Salesforce superstars provide great mock exams for many of the Salesforce certifications. The quality of these is higher, and I recommend them for testing your knowledge, but I urge you not to be lulled into a false sense of security.

On mock exams, I was getting close to 100% and was totally confident I was going to ace the real exam. The truth is the official Salesforce Certified Administrator credential is a killer, with much longer/trickier scenario-based questions than any of the mock exams I have seen. Many other Salesforce Certified Professionals agree this is the toughest exam they have done so far because it is so broad.

You can do it!

Don’t let this post put you off aiming for this credential. If I can do it, so can you. However, don’t waste your money sitting the exam if you’re not ready. It costs $200 for the first attempt and $100 for every attempt thereafter.

The first step described in this post is crucial – identify your strengths and weaknesses, and focus your learning. If you take this approach and cover everything in the exam outline in the study guide, you will pass.

I find Salesforce exams really nerve-wracking. Doing them from home also makes them prone to things going wrong. I have had Internet connections drop mid-way through exams, cats jump on the table and walk across my keyboard, and window cleaners try to chat to me through the glass, all while the timer was ticking and that little webcam was silently watching my every move!

Despite these challenges, I survived the experience and have now passed several Salesforce exams. You can do the same.

Did this post help you?

If these tips helped you, please share the love by leaving a comment and/or sharing with your Salesforce Ohana!

Image credit: photo by Green Chameleon on Unsplash.

The Never-Ending Salesforce Learning Journey

The learning never stops with Salesforce!

Salesforce Tower
Approaching the mothership: The ‘Salesforce Tower’ at 110 Bishopsgate, London.

I work in the Salesforce ecosystem as a Solution Architect, and am well aware of how regular changes to the platform (three releases per year) mean we are all on a constant learning journey.

It’s not just about frequent releases, there are also many different products that work together to make up the Salesforce Customer Success platform, and Salesforce Consulting Partners are increasingly insisting that their consultants be certified for those products before they can work on real client projects.

Getting certified means studying and learning – therefore, I’m going to start writing about my experience with Salesforce certifications here on this blog.

I’m also going to be sharing Salesforce tips when I discover something that I think may be useful to others working in the Salesforce ecosystem.