A common issue sales reps run into in Salesforce is the existence of leads in their database that are current customers. They end up calling the prospect trying to pitch their product and the person tells them "We are already a customer of yours". Few things are worse for a sales person than cold calling your existing customers. Leads come into Salesforce from web forms, white paper downloads, etc. and nothing is checking for whether they are a current customer or not.
We have developed an AppExchange package that relates a Lead record to an Account record by looking for a match between the Lead's email address domain and the Account's website domain. While this doesn't find all of the leads that could exist for your Accounts, it does help. Here are the components in the package:
- Account | Relate Leads by Website (Process Builder)
- Lead | Relate to Account by Email Domain (Process Builder)
- Account | Relate Leads to Accounts (Autolaunched Flow)
- Account (Custom field on the Lead object) - this is a lookup field to the Account object.
- Email Domain (Custom field on the Lead object) - this is a formula field
- Website Domain (Custom field on the Account object)
- Website Domain and Path (Custom field on the Account object)
How to Configure the App
- Install the AppExchange package into a sandbox environment.
- Go to Setup | Flows and Activate the flow called Account | Relate Leads to Accounts
- Go to Process Builder and Activate both processes: Account | Relate Leads by Website and Lead | Relate to Account by Email Domain
- Update field level security for the fields for the necessary profiles.
- Go to Leads | Page Layouts and add the Account field to your Lead page layouts.
- Go to Accounts | Page Layouts and add the Leads related list to your Account page layouts.
That's it, you are ready to test out the app!
Website Domain Fields & Formulas
Now we have to give credit to Walter Pelowski from the Salesforce developer community for the formulas he created for the fields called Website Domain and Website Domain and Path - you can see his post here. Thanks Walter!
We can see how amazing his formulas are, they solve for every scenario we have tested with. Here you can see it in action, we have Website = www.bluninjas.com/blog and the Domain correctly shows bluninjas.com.
How to see if a Lead is related to an Account
- When a new Lead is created in Salesforce or the Lead's email address is changed, the process builder called Lead | Relate to Account by Email Domain is triggered. This process invokes the flow called Account | Related Leads to Accounts. The flow looks for existing accounts records where the value in the Website Domain field matches the Email Domain field on the Lead. If it finds multiple Accounts with the same domain, it sorts the list by Last Activity Date and the most recent date is chosen as the Account to relate to the Lead. The flow then updates the Account field on the Lead.
- Here is what it looks like from the Lead:
- Now that your Lead is related to the Account, you can do things to help your sales reps out. You can show/hide text based on whether the Account is a customer so they do not call them. Or you could take it one step further and automatically convert the lead to a contact under the customer's Account record.
What Happens if an Account's Website Changes?
If you change the value of the Website on the Account, the process builder called Account | Relate Leads by Website is triggered and it will invoke the flow called Account | Related Leads to Accounts. The flow will now go down a different path and will check to see if the current Leads related to the Account have an email address domain that matches the website domain of the Account. If it doesn't match, the Account field on the Lead is updated to be blank. Then the flow looks through the other Leads and checks for matches. When it finds a match, it updates the Account field on the Lead record.
Now you are ready to move onto configuring the 2nd part of this app - Mass convert leads from the Account page. See this article for complete instructions.
Any comments, questions, concerns – let us know in the comments! We would love to hear from you!
7 thoughts on “Relate Leads to Accounts”
When I tried to install this in sandbox, it is installing in production. pls advice
Thank you so much for catching this. I had only updated one of the links in the blog to link to a sandbox, the one you clicked on was configured to install in production.
To install it in the sandbox, use this link: https://test.salesforce.com/packaging/installPackage.apexp?p0=04t3j000001Faos
To install it in production, just replace ‘test’ with ‘login’ in the URL. This app is not a paid app, it is totally free and an unmanaged package, so you can see all of the components in it and you do not have to pay for it ever.
Thank you for your interest in our app! Hope this helps!
It worked really good, thank you!!
Thank you! This is a great app and exactly what we were looking for – I do have a question! It looks like the lead field in the account section is not coming up as quick list. We had an existing lead field at the account level and I’m thinking this is what caused the confusion when I installed the app? Can I manually add this field with the formula?
So happy you found this helpful! Please confirm which version of the App you are using. In version 1.2, we renamed the API names to have BN in front of the field name to prevent these types of issues. Are you referring to the Email Domain field on the Lead object?
Thank you for this app! Question, have you had any trouble with PB firing with bulk uploaded leads? I’m in a situation where it does not seem to trigger PB to fire the account | lead flow.
This is usually a batch size issue. If you update the settings in data loader to have a Batch Size <= 200, this should work. The more automated processes you have running on an object, the smaller your batch size has to be when running mass updates. Please try this and let me know if it works.