Auto Fill Opportunity Name with Account Name

Posted March 19th @ 2:12 pm by Darren

Opportunity Name Best Practice

As a best practice, Saleseforce.com recommends that you prefix your opportunity names with the corresponding account name. Let’s say you have a sales opportunity for 50 widgets under the ABC Company account. The opportunity should be named:

“ABC Company - 50 Widgets”

This just makes it easier when you see an opportunity in a report or the recent items list. If you don’t put the account name in the opportunity name then you may end up seeing a whole bunch of opportunities that are labeled “50 Widgets”. That can cause a lot of headaches later on when you see a list of opportunity names but you can differentiate which account the opportunity belongs to. This is so important that when you convert a lead, Salesforce will automatically prepend the new opportunity name with the account name.

But the question I always get is: “How come Salesforce doesn’t do that when I create an opportunity from an account or contact record?”

I’m going to show you a little trick that I have used for a couple of customers.

Goal: Right now when you’re on an account or contact record and you click ‘New’ to create an opportunity, the opportunity name is blank and sometimes sales reps will forget to properly name the opportunity as mentioned above. With this trick we’re going to replace the ‘New’ button. This custom button will now automatically fill in account name into the opportunity name whenever you create an opportunity from an account or contact. That will ensure that all opportunities are named according to the best practice suggested by Salesforce.

Before we begin, you may want to do this during off hours so that you can test it without disruption. It will only take 5 minutes so you won’t be putting in too much OT :-)

First we need to create a new custom button on the opportunity.

  • Click Setup > Customize > Opportunities > Buttons and Links
  • Under the Custom Buttons and Links related list click ‘New’

Fill the form in with the following fields:

  • Label: New
  • Name: New
  • Display Type: List Button
  • Behavior: Display in existing window without sidebar or header
  • Content Source: URL

Copy and paste this expression into the text box and then click ‘Save’:

/006/e?retURL=%2F{!NULLVALUE(Contact.Id, Account.Id)}&accid={!Account.Id}&conid={!Contact.Id} &opp6={!Contact.LeadSource}&lookupcmpgn=1&opp3={!Account.Name} -

Click to enlarge screenshot:
Click to Enlarge

Next you’ll have to go to the account and contact page layout to swap the standard ‘New’ button with our custom made button on the opportunity related list. To do this follow these steps:

  • Click Click Setup > Customize > Accounts > Page Layout
  • Click ‘edit’ beside the page layout
  • Scroll down to the ‘Related List Section’ and double click ‘Opportunities’

A new menu should pop up. And follow these steps.

  • To make sure these changes are made on all account page layouts check each box under the ‘Other Layouts’ section (view screenshot)
  • Hide the standard ‘New’ by un-checking the box beside it
  • Under the ‘Custom Button’ section add our ‘New’ button to the selected list
  • Click ‘ok’ to close the pop up menu
  • Remember to click ’save’ on the page layout

Click to enlarge screenshot:

Click to Enlarge

Now repeat these same steps for the contact page layout. After you have done so, test it out! Open any account record and try creating a new opportunity from the related list. Then open any contact record and do the same. You should see that the opportunity name is always prefilled with the account name just the way we like it.

Don’t understand how that code works? Don’t worry, I’ll be posting a follow up to explain the details of the code.

Update:
Here is the follow up post that I promised. Click here to learn more about the code and the trick I used.

Advertisement


-->

1 Trackbacks/Pingbacks

  1. Pingback: Salesforce URL Explained | Warrior Point - Latest News on SaaS & Tutorials for On-demand Software on March 30, 2008

2 Comments

  1. Luigi Montanez
    March 19, 2008 at 20:53

    Thanks for this! I’ve thought of solutions to this very problem, but it’s never occurred to me to do it this way, which is now obvious with the benefit of hindsight. Very, very helpful.

    (btw, I don’t think your OpenID login is functioning properly)

  2. Darren
    March 27, 2008 at 19:33

    Thanks! You’re right. I’m removing the OpenID until we resolve the issue.

Leave a comment

Standard Login

Options:

Colors