Play with Custom Links: Part 2
In my last post I explained how to build a simple web custom link; more complex custom links can be used to pass data from your Salesforce records, user information, or company information to another website or application; it can also be used to pass variables from one Salesforce object to another.
Let’s see how to create a custom link to pass fields values from a Salesforce object to another.
Scenario
We give support to different companies and accordingly to what kind of support type a company has, their cases have to be handled differently. We’ve created a custom field for the Account object called Support Type, of type Picklist, containing the variables: “Silver, Gold, Platinum“; we created the same Support Type field for the Case object, same type, same picklist values. We now need to create a custom link in the Account object so when we click on it, we get redirected to a Case page where Account Name and Support Type are filled accordingly to the values present on the Account record.
How to proceed - a step by step guide
First of all we need to find out where in the Case record page our values are going to be “written” to; we basically need to find out the ID of the HTML INPUT fields: Support Type and Account Name.
UPDATE: In order to find a field’s ID please check this post
Let’s now move to: Setup | App Setup | Customize | Accounts | Buttons and Links, click on the New button, specify a Label (eg: “New Case”), the Name will be filled in automatically, select the Display Type, the Behavior, make sure the Content Source is URL.
We’re now about to start writing our custom link; the last thing we need is the Object’s code for the Case object: 500 (where did I get this from? Did you read all the old posts? ;)).
- Our custom link will start with: /500/e? which points to the edit page of a new case record.
- Now we can pass the variables: cas4, the ID of the Account Name INPUT field in the Case object, will have to contain the actual account name, so we can write cas4= and select Account Name from the Insert Field drop-down list. This will automatically insert {!Account.Name}.
So far we have:
/500/e?cas4={!Account.Name} - We have to add an & (ampersand) within the variables.
- 00N20000000thpg, the ID of the Support Type INPUT field in the Case object, will need to contain the value of the selected account’s Support Type field, so we can write 00N20000000thpg= and select Support Type from the Insert Field drop-down list. This will automatically insert {!Account.SupportType__c} in the textarea. So far we have:
/500/e?cas4={!Account.Name}&00N20000000thpg={!Account.SupportType__c} - Doesn’t it look good?
And it’s almost complete. We can add a retURL to point the user back to the account’s page when the case is saved. Just add retURL=/{!Account.Id} and we’re done! All together!:
/500/e?retURL=/{!Account.Id}&cas4={!Account.Name}&00N20000000thpg={!Account.SupportType__c}
This should give you an idea of how a custom link works. I hope I’ve been clear enough, if you have any question, just add a comment.
Popularity: 14% [?]
12 Comments, Comment or Ping
Hi,
This is perhaps the most lucid article on custom links. I am up to creating complex custom links from the home page and was always wondering about the format of URL. Your article has definitely given me start to begin my search.
Thanks,
Manish
Hi Ale
I would like to express my appreciation to you on the above well written and clear guideline on how to handle custom links. I have been able to solve what I need successfully after such a long struggle - thanks a million to your article
SL
This is great info. I wish I would have found something this succinct when I learned myself on Web Links earlier this year.
On an advanced level is there anyway to use a web link to create a Case and have the Owner Value be populated with anything other than the default user value of the record creator? We have admins who are creating cases for users. The button that launches a new case uses web links to auto fill some fields but I have been unable to find a way to use them to assign record ownership.
I’ve searched and searched and have a feeling that this might not be possible using the url to pass info. Any Ideas?
this is fantastic and very helpful.
As they say - beware those with a little knowledge
Is it possible to perform the functions of 2 URLs?
for example, an opportunity I want to set a custom field to true, set the opportunity stage and ALSO create a new activity with a number of params passed over. I have been able to do both functions independently but can they be joined together?
I as trying somthing like this:
/{!Opportunity.Id}/e?00N70000001aE8t=”true”&opp11=”Attending Launch”&save=save&retURL=https://na5.salesforce.com/00U/e?&evt3_lkid={!Opportunity.ProjectId__c}&evt3={!DevelopmentProject__c.Name}
any help appreciated.
Cheers
Ken
This is exactly what I was looking for! I was about to pull my hair out when I finally found this - thank you so much!!!
Hi
Your artcle is very informative. Do the same rules apply to reports. For example I am try edit the custom link to WIL - Time Left on Service Contracts 2 supplied by salesforce which does not work. its support to filter for contract but it does not.
Article très intéressant mais hélas encore une fois, il n’ai pas dans la langue de Molière.
Your article did a lot good to me. One of my requirements is entirely based on it. However, I just fear that deploying my app in another org might change the field id and my app may not work. Is there any way to get field id by using field name (e.g. String fldId=getFieldIdByName(’Case.My_Custom_Object__c’);)?
$64,000 question - will this be supported in future Salesforce release?
this is great. however i cannot seem to get the lookup fields to be automatically filled in. is there a reason why?
Is it possible to dynamically get the id for a custom field?
on 4 Apr 2007 @16:10
Reply to “Play with Custom Links: Part 2”