Decoding Salesforce

Decoding Salesforce

The hows and whys of Salesforce.com

Posts Tagged ‘Custom Links’

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 :D

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? ;) ).

  1. Our custom link will start with: /500/e? which points to the edit page of a new case record.
  2. 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}
  3. We have to add an & (ampersand) within the variables.
  4. 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}
  5. 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. :)

Play with Custom Links: Part 1

From Salesforce’s Help&Training: “Your organization’s Administrator can set up Custom Links for Home, Campaigns, Leads, Accounts, Contacts, Opportunities, Cases, Contracts, Solutions, Products, Assets and Users. These Custom Links allow your organization to link salesforce.com data with your back-end office systems. They can be directed to external URLs or to your company’s intranet. In addition, the administrator can specify fields to be included as tokens within the URL. For example, you could include an account name in a URL that searches your accounts-payable system“.

These “tokens” are normally called Merge fields; “Merge fields serve as placeholders for data that will be replaced with information from your records, user information, or company information“.

Suggested trainings

A simple web custom link

We can create a simple custom link to search on google.com for an account name:

http://www.google.com/search?q={!Account_Name}

where:

  • http://www.google.com/search?q= is the URL we use to search on google;
  • {!Account_Name} is the merge field for the account name.

We are ready now to create the custom link, so login to your Salesforce organization and:

  1. Click on: Setup > App Setup > Customize > Accounts > Buttons and Links > New
  2. Specify a Label (eg: “Google Account Name”)
  3. The Name will be auto populated
  4. Select the Display Type
  5. Select the Behavior
  6. Make sure the Content Source is URL
  7. Copy&paste the custom link:
    http://www.google.com/search?q={!Account_Name}
  8. Click Save

You can display all the available Merge fields by selecting the Object in the Select Field Type picklist, and the relative field in the Inster Field picklist.

The Link URL you enter can be up to 3000 bytes. When data is substituted for the tokens in the URL, the link may exceed 3000 bytes. Your browser may enforce additional limits for the maximum URL length. Maximum URL Length is 2083 Characters in Internet Explorer, not sure about Firefox, definitely more than 65536.

Update: the 2nd part of the tutorial is available here. :)