
This is the second part to the tutorial I presented last week about Automatically filling in the Account Name when entering the Opportunity Name. This tutorial will go into a little detail about the structure of a Salesforce URL and I’ll explain the code that we used last time.
Let’s get started, first you need to understand how the URL works.
The Basic Breakdown
First click the Opportunity tab. You get to the Opportunity Home page and the URL should look something like this:
https://na3.salesforce.com/006/o
So let’s dissect this. The na3 in the URL is the Salesforce server that hosts your application for your org. In this case, na3 means North America 3. The /006 is an ID for the object that you clicked. In this case 006 is the ID for the Opportunity object. The /o just means object home page. So altogether you have a URL that says “take me to the Object Home page for object 006″. If you change that 006 to 001 and hit enter, you should get to the Account Home page.
Introducing Parameters
Go back to the Opportunity Home Page and click new. The URL should now look like:
https://na3.salesforce.com/006/e?retURL=%2F006%2Fo
Now this is the exact same URL as before with a few changes. Notice you should still be on the same server and Object ID is still 006. But now instead of /006/o we have /006/e. The e means edit and that’s why you’re on the Opportunity Edit page. The ? is a standard way to denote the beginning of parameters in a URL. Notice the retURL parameter is set to %2F006%2Fo. The retURL parameter tells the application where to direct the user when they click ‘Cancel’ or ‘Save’. In this case %2F006%2Fo is a placeholder for the Opportunity Home Page. If you set the retURL to a specific record ID you will return to that record when you finish editing.
Add this to the end of the URL and press enter:
&opp3=Warrior Point -

Observe the Opportunity Name field. In general you can pass many parameters after the ? (question mark). It’s pretty straight forward. You specify the parameter name equal to some value. And each name/value pair is separated with an & (ampersand). In general it looks like this:
/006/e?param1=value1¶m2=value2¶m3=value3 …
Most standard and custom fields on any object can be pre-filled using a URL parameter. You just need to figure out the corresponding parameter name. In this case, the parameter opp3 corresponds to the field for Opportunity Name. For instructions on how to find the parameter name of a field visit: Decoding Salesforce.
Our Example
I used this exact technique when creating that ‘New’ button from our last tutorial.
Recall the formula we used for the ‘New’ button:
/006/e?retURL=%2F{!NULLVALUE(Contact.Id, Account.Id)}&accid={!Account.Id}&conid={!Contact.Id} &opp6={!Contact.LeadSource}&lookupcmpgn=1&opp3={!Account.Name} -
As you can see these are the parameters that we set:
- retURL=%2F{!NULLVALUE(Contact.Id, Account.Id)}
- accid={!Account.Id}
- conid={!Contact.Id}
- opp6={!Contact.LeadSource}
- lookupcmpgn=1
- opp3={!Account.Name} -
Let’s go through each in detail:
| retURL: | We set this parameter as the Contact Record ID or if that’s null, the Account Record ID. This will take us back to the right Account or Contact record after we create the Opportunity. |
| accid | This is the parameter for the Account field on an Opportunity. This is a lookup field so notice it has to be an Account ID and not Account Name. |
| conid | By setting this parameter, the contact is designated as the primary contact in the contact roles of the Opportunity. |
| opp6 | This parameter sets the Lead Source field in the Opportunity. We’ll set the Lead Source equal to the Lead Source on the contact. That’s the standard behaviour right now. |
| lookupcmpgn | This is just a flag. When we set it to 1, Salesforce assigns the latest campaign from the Campaign History of the Contact to the Campaign field on the Opportunity. |
| opp3 | This is where our trick kicks in. opp3 is the parameter for the Opportunity Name field. We automatically merge the Account Name and a hyphen into the name. |
That’s basically the trick. We’re setting that Opportunity Name field through the URL. After the you implement the New button try it out and check out the URL. You’ll notice the Account Name is actually embedded into the URL.
Small Note: Some of you may be wondering why we don’t need the “na3.salesforce.com” in the URL formula. We’re using relative links and that basically means that the server and domain doesn’t change. In fact your browser will fill in that information automatically. I recommend using relative links in a formula. If Salesforce.com ever moved your organization on to a different server (from na3 to na2) then all the buttons and links you create won’t work.
More Uses of this Trick
This an incredibly helpful trick. You can merge information into fields and pass it through the URL just like I did. I’ll give you another scenario in which I used this trick. Let’s say you have a Sales Order object. A Sales Order is a child object to Account. So if you want the Sales Order to automatically ‘inherit’ information from the Account you can replace the ‘New’ button much the same way I did. For example, you may want the Order to be automatically pre-filled with the Account address whenever you create a new Sales Order.
Stay tuned, I have one more way in which this trick can be used.

August 5, 2008 at 15:19
Hi, first off I wanted to thank you for a great tutorial. I am able to find standard and custom field IDs via:http://salesforce.phollaio.com/2007/04/02/how_to_obtain_a_field_id/
What I would like to really know is if there is an documentation for additional paremeters such as: conid, accid, lookupcmpgn? Where can these be found? I would love to be able to setup a specific contact role for an opportunity in addition to just setting the Contact Role as primary via: conid.
Thanks!
August 7, 2008 at 00:54
Hi Tanner,
Thanks for the comment.
Just thinking off the top of my head … I don’t think that’s possible.
Those Contact Roles are almost an object in itself. I’ll have to do some more playing around to confirm but I think that scenario you mentioned is too complex.
You might be limited to just using the conid.
October 2, 2008 at 15:23
Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks!!4
May 13, 2009 at 07:41
Hi!
How to overcome issue if you have special characters e.g. é, ó, á etc. in a SFDC field ?
Then for example my url would be:
/006/e?param1=válúe1
This passes ok to the corresponding SFDC picklist field with Firefox, but IE it does not pass. I have tried to URL encode the values but with no success…
any help?
May 18, 2010 at 15:20
This is a great tutorial. What I am looking for is how to have a formula on one page that references another object as a hyperlink. I thought the retURL was the correct function but now I am not sure based on your explanation. Can you provide some suggestions?
Thanks — Kerri
June 4, 2010 at 15:47
What is the Send Notification Email Field Id? Where is the official Salesforce.com documentation for this located?