Using Key Prefix to Identify Object Types in Salesforce.com


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.

  1. Daniel Ballinger’s FishOfPrey.com: Obscure Salesforce object key prefixes
  2. 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"))

Reference

  1. Daniel Ballinger’s FishOfPrey.com: Obscure Salesforce object key prefixes
  2. Salesforce Hacker: A very little key [prefix] will open a very heavy door
  3. Salesforce: Workbench
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s