Salesforce Admins: Save time with Custom Buttons

This is a technique we use frequently with our clients. It helps save time by prepolutating fields for your users. For example, have you ever wished you could prepopulate the Organization Name or Contact Name fields when creating new donations or volunteer applications? 

It requires manipulating URL and a formula but once you have an example, it becomes a lot easier. Today I'm going to share an example where we will set the Membership Start Date field on a new membership record.

Step 1: Create a new button

1. Because our button will create a new membership opportunity, we have to create the button under Opportunities. Setup | App Setup | Opportunities.


2. Click on the New button and make sure you setup the options as indicated below. (Select List Button and Display in existing windows with sidebar)


3. Modify the secret sauce

Did I lose you? Here is how to decipher the code:

/006/e?&: Indicates what type of record should be created. A new Opportunity in our case.
retURL=%2F{!Contact.Id}&: Indicates that the user will return to the Contact once the Opportunity has been created/saved. 
cancelURL=%2F{!Contact.Id}&: Indcates that the user will return to the Contact if the Cancel button is pressed.
RecordType=012C00000004XQC&: Sets the Opportunity record type.
conid={!Contact.Id}&: Sets the Contact Role.
opp4_lkid={!Account.Id}&: Prepopulates the Organization Name field.
opp4={!Account.Name}&:  Prepopulates the Organization Name field.
opp3={!Contact.FirstName} {!Contact.LastName} Membership – {!Today}&: Prepopulates the Opportunity Name.
opp9={!Today}&: Prepopulates the Close Date with today's date.
00NC0000004JlXh={!Contact.npo02__MembershipEndDate__c}&: Prepopulates the Membership End Date.
opp11=Closed Won": Prepopulates the Stage field.


To simplify a bit, the above code is a list of "field=value" separated by a '&'. For field value, remember you can use

  • a static value (opp11="Closed Won"),
  • a mailmerge field   opp4={!Account.Name}

In order to find the field name, go to the field defintion, inspect the URL which will contain the field name you should use.


Step 2: Add it to the page

4.  After clicking Save, you now have to add your newly created button to a page layout.


5. Since we need the button to be on the Contact record in order to allow users to create new membership from a member, we need to Edit the Contact layout.


6. From a contact record, click on the "Edit Layout" shortcut (you may also use quick menu on the right side).


7. Scroll down to the Opportunity related list on the Page Layout editor and click on the wrench. Expand the Buttons section and make sure your new button is in the "Selected Button" box.


8. Click OK.

The result is that when I click on the new button

When clicking on this new button, a new Opportunity screen is presented with the Membership Start Date prepopulated.

No more need to ask users to populate the Membership Start Date, reduce mistakes. There are tons of usage for this trick. Have you used it? How?



Pierre Kaluzny is a certified Salesforce consultant and the founder of Sputnik Moment. He constantly challenges himself to solve problems to ensure his clients' needs are met. Connect with him on LinkedIn to discuss more creative ways your organization could leverage Salesforce and make use of custom buttons.