Lead Website Seeker

FacebookTwitterGoogleLinkedInEmail this page


When you’re checking out a Lead in salesforce, it’s handy to be able to click the Website field to go to the Lead’s company website. But what if you don’t have the website field populated? And let’s be honest, it’s rarely populated. This nifty link will use the Email and Company fields to “seek” the website for you!

The basic premise is that even though you don’t have a website on the record, you usually have enough information available to find the website pretty easily. For example, I know I usually check out the email address of the Lead as it most likely contains the domain of the website. So that’s what the product of this recipe does, checking first to ensure the domain is not a common email service domain like “gmail.com” or “yahoo.com” for example.

When it hits one of these generic domains, or if the Email field isn’t populated, then it makes a best guess using the Company field, since this field is required. In order to make a guess at what the website might be using the Company, it swaps any ampersands with the text “and” and then it removes all other special characters that are not allowed in domain names. Lastly it slaps a “.com” at the end. So, for example, a Lead with a Company of “Bed, Bath & Beyond” produces “bedbathandbeyond.com” by this method… not too shabby.

So, once it has found or concocted a guess at the website, it opens a new window at that address.  Here is a flowchart:

Although obvious, I must note that this method is NOT going to work 100% of the time. For example, because “.com” is the most popular suffix among companies that’s what we use in our last ditch effort… so it clearly will not work for “.net” or other domains. Also, it is only checking for a handful of the most popular email domain services. There are many more out there such as internet provider emails, university emails, etc. Anyhow, you get the point… it makes an educated guess at what the website might be, and does a pretty good job for only 21 lines of code. 🙂

Ingredients:

1 Custom Link

Instructions:

I will provide the instructions for creating the “Website Seeker” link on the Lead object, although by simply modifying the merge fields in the code below you could make it work for Contacts or Person Accounts.

Step one is to go to “Leads” in the setup menu under “Customize”, then “Buttons and Links”. Click “New” and give your link a cool label, like maybe “Surmise Website” or “Company Website Hunter” or something like that. Then choose “Detail Page Link” and set behavior to “Execute JavaScript”. Then copy and paste the code below into the body, and Save. The final step is to add this new link to any desired page layouts.

Then go try it out on a bunch of Leads… makes a great party trick!

var website = ‘{!JSENCODE(Lead.Website)}’;
var email = ‘{!Lead.Email}’;
var company = ‘{!JSENCODE(Lead.Company)}’;
var targetURL = ”;// IF WEBSITE FIELD IS POPULATED WE GO THERE, NATURALLY

if(website != ”){

// CHECK IF WE NEED TO ADD http:// OR NOT
if(website.indexOf(‘//’) != -1)
targetURL = website;
else
targetURL = ‘http://’ + website;
}

// NEXT WE CHECK OUT THE DOMAIN OF THE EMAIL ADDRESS

else if(email != ”){

var domain = email.substring(email.indexOf(‘@’) + 1,email.length);

// WE FILTER OUT COMMON EMAIL DOMAINS
if(domain!=’gmail.com’ && domain!=’yahoo.com’ && domain!=’hotmail.com’ && domain!=’me.com’ && domain!=’excite.com’ && domain!=’aol.com’)
targetURL = ‘http://’ + domain;
}

// IF NO TARGET FOUND YET WE TAKE A STAB USING COMPANY

if(targetURL==”){

targetURL = ‘http://’;

// FAIR ASSUMPTION IS TO SWAP ‘&’ for ‘and’
company = company.replace(/\&/g,’and’);

// STRIP OUT INVALID DOMAIN CHARACTERS
targetURL += company.replace(/[^a-zA-Z0-9|\-]/g,”) + ‘.com’;

}

// FINALLY WE OPEN A NEW WINDOW DIRECTED TO OUR TARGET URL

window.open(targetURL,’_blank’,”,false);

 

1 Comment

  1. What i do not understood is in reality how you’re now not actually much more neatly-favored than you may
    be right now. You’re so intelligent. You know therefore considerably relating
    to this matter, made me personally consider it from numerous various angles.
    Its like women and men don’t seem to be fascinated unless it’s one thing to do with
    Woman gaga! Your individual stuffs great. Always care for it up!

Leave a Reply


Your email address will not be published.


*