Salesforce.com keeps some useful information in URL. It could be used on redirecting page, identifying objects types, switching records, and etc.
Key Prefix of Standard Objects
There are two useful posts about key prefix of salesforce.com objects. They explain the URL structure and provide a list of standard object key prefix.
- Daniel Ballinger’s FishOfPrey.com: Obscure Salesforce object key prefixes
- Salesforce Hacker: A very little key [prefix] will open a very heavy door
Key Prefix of Custom Objects
For custom objects, it begins with ‘a01’, ‘a02’, and etc. I create two custom objects and add test records. After comparing URLs of each record to get this rule of my org.
A more reliable method is to use Salesforce Workbench. It helps exploring details of any objects. Use menu [Info] → [Standard & Custom Objects] to select. The object key prefix is keyPrefix in Attributes folder.
Use Formula Field to Identify Object Type
With key prefix, I may add a formula field to categorized the object type of Name field in Activity object.
IF( LEFT( WhoId,3) == "003", "Contact", IF(LEFT(WhoId, 3) == "00Q", "Lead", NULL))
For object type of Related to field in Activity object, here is a sample to identify Opportunity and Account objects:
IF( LEFT(WhatId,3) == "006", "Opportunity", IF(LEFT(WhatId, 3) == "001", "Account", "Undefined"))