Use a Custom Button to Pre-Populate Opportunity fields

A major hurdle for many marketers is understanding which programs are driving Opportunity creation versus which programs are driving Opportunities to close. Some commonly used fields to track this data are: Lead Source, Lead Source Details, and Primary Campaign Source.

By default, Salesforce will map Lead Source and select a Primary Campaign Source if an Opportunity is created through lead conversion. Otherwise, a sales representative creating the opportunity would need to manually fill in those fields, which is not ideal for tracking accurate data. A trick to ensure that accurate Marketing data makes its way onto the Opportunity is to create a Custom Button on the Contact page which creates a new Opportunity and dynamically pulls the correct data through to the Opportunity.

The first thing you need to do is navigate to Setup > Customize > Opportunities > Buttons and Links > click New.

Then, name the button, write a description, select “List Button” (because we want this visible on the Opportunities related list,) and select “Display in existing window without sidebar or header.”

We’ll then want to start building the URL, which will end up looking something like:{!Contact.Id}&ent=Opportunity&conid={!Contact.Id}&opp6={!Contact.LeadSource}&00NC00000052b2F={!Contact.Lead_Source_Detail__c}

The URL is made up of a series of elements separated by & symbols, each of which affect the opportunity creation in different ways.

  • associates most recent Campaign as Primary Campaign (lookupcmpgn=1)
  • returns the user to the Contact record if Opportunity creation is canceled (retURL=%2F{!Contact.Id})
  • recognizes that we are creating a new Opportunity (ent=Opportunity)
  • associates the Contact as the Primary Contact on the Opportunity (conid={!Contact.Id})
  • pulls the Contact’s Lead Source to the Opportunity’s Lead Source (opp6={!Contact.LeadSource})
  • pulls the Contact’s Lead Source Detail to the Opportunity’s Lead Source Detail (00NC00000052b2F={!Contact.Lead_Source_Detail__c})

While Primary Campaign Source and Lead Source are standard Salesforce fields, Lead Source Detail is not. To pre-populate a Custom Field, you need to find the field ID for the custom field. Do this by navigating to Setup > Customize > Opportunities > Fields > Custom Fields > Lead Source Detail > and copy the ID which resides after

Then, in the Custom Button URL, append: &CustomField ID={!Contact.Lead_Source_Detail__c}. I’d recommend using the Insert Merge Field functionality whenever possible to avoid any typos.

Once this button is in place, it will be important to enforce rep behavior to only create Opportunities through (1) Lead Conversion and (2) our new custom Button on the Contact record.  This process will ensure Contact record is associated to the Opportunity record with a Primary Campaign Source, Lead Source, Lead Source Details and any other custom fields you choose to map.

How have you used a custom button to pre-populate fields on other objects?

Photo credit: alandberning