Help reduce duplicate Salesforce Accounts/Contacts from Leads

Help reduce duplicate Salesforce Accounts/Contacts from Leads

 

WARNING: This post was created in 2011 and has been un-tested since. Salesforce now supports duplicate checking via ‘Duplicate Management’

Earlier in the month I posted about a little app I created to search existing Contacts within Salesforce based on a Lead that your looking at. Well I’ve had interest from people in creating this as a full app. So I’ve packaged up the initial version up so you can install it and take a look:

How to install:

  1. Click the following link, this will ask you to login you can either install it into your sandbox or production if you don’t know what I’m talking about when I say sandbox just click the production link:
    Production: https://login.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04tC0000000jNAN
    Sandbox: https://test.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04tC0000000jNAN
  2. You will be asked to login using either your production or Sandbox user details.
  3. Salesforce will then show you a wizard to install the app (you can always un-install the app if you don’t like it), you can mostly click next next next etc on the wizard. But one section to be aware off is the permissions about who can see the application. You can either allow only administrators to view the app, everyone or a sub-set of people.
  4. Once you have run through the Salesforce install you need to add the “VisualForce page” to your lead page layout. The easiest way to do this is to view any lead from within Salesforce and click the link ‘Edit Layout’ which can be found on the top right hand corner.
  5. Next the best thing to do is create a section on your layout to put the “VisualForce page” click and drag the “Section” box onto the lead layout. This will pop up a box and ask you to fill in some details. Call the Section name “Search Contacts” or something like that. Select the “1-Column” layout and click OK.
  6. Select the “Visualforce pages” option and you will see the “searchContacts” visualForce page. Click and drag this down on top of your section that you have just created.
  7. Click Save.
  8. Bingo your done! You’ll now see the the search box on your Lead

New requested features:

The following is a list of features that people have asked for which I will be developing into the app hopefully over the next couple of weeks:

  • Ability to click on the contact name and go to the contact rather than having to go via the account.
  • Ability to use the user’s permissions rather than returning contacts that they may not have access too.
  • Ability to search leads as well as contacts.
  • Show a message “No Contacts found” if no matching records could be found.
  • Don’t just search on email address but do a bit of a fuzzy search on company name / persons name etc..

Have fun with it and please let me know on any additional features you would like!

Searching existing contacts based on a lead

Searching existing contacts based on a lead

I went to the London user group last year and quite a few people were interested in an app which when your looking at a lead automatically searches for existing records within salesforce. So I’ve just created a quick Salesforce app to allow you to search existing contacts based on a lead. It only searches contacts at the moment but I’ll get it to search other objects too if people are interested in it. Its also limited to just searching based on email address at the moment as well, but again if people are interested i’ll expand it.

If you want it give me a shout and i’ll send you a link to the package so that you can install it in your org, a “one click” install. But if your feeling adventuous and want to do it manually you can follow the brief instructions below, but you do need to know the basics of how to edit and create apex classes and pages:

Create searchContacts class:

public with sharing class searchContacts {

private final Lead thisLead;
public Contact [] contactObj { get; private set; }

public searchContacts(ApexPages.StandardController stdController) {
this.thisLead = (Lead)stdController.getRecord();

}

public Contact [] getContacts(){

System.debug('controller Id: ' + this.thisLead.Id);

Lead EmailAddress = [Select l.Email from Lead l WHERE l.Id = :this.thisLead.Id];

System.debug('getContacts Lead: ' + EmailAddress);

contactObj = [Select
c.Name,
c.AccountId,
c.Email,
c.FirstName,
c.Id,
c.LastName,
c.Salutation,
c.Title
from Contact c
WHERE c.Email = :EmailAddress.Email ];

return contactObj;
}
}

Create a searchContacts Page:
<apex:page standardController="Lead" extensions="searchContacts">
<apex:pageBlock >
<apex:pageBlockTable value="{!contacts}" var="item">
<apex:column value="{!item.Name}" />
<!--            <apex:column value="{!item.Id}" />-->
<apex:column value="{!item.AccountId}"/>
<apex:column value="{!item.Title}" />
<apex:column value="{!item.Email}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

In the page above i’ve just pulled out Name, AccountId, Title & Email fields, but if you have custom fields or other fields you want to pull out just copy one of the apex:column lines and change the field name (!item.xxxxx)

Next all you need to do is add the visualforce page to the Lead page layout, also don’t forget if you have different profiles that you go in to them and give access to the visualforce page otherwise other users won’t be able to see the visualforce page.

Bingo!