<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Recent Comments on Idea</title>
  <entry>
    <title>mtbclimber commented on Function to determine object type for whoId and whatId</title>
    <author>
      <name>mtbclimber</name>
    </author>
    <updated>2008-07-25T22:46:00Z</updated>
    <link href="http://ideas.salesforce.com/article/show/10087660/Function_to_determine_object_type_for_whoId_and_whatId"/>
    <content type="text">If all you want is the name then you can do this today with SOQL relationships. For example:

[Select Who.name from task where id = :taskid];

Polymorphic relationships like who and what on task/event or owner on queue-ownable objects can be traversed. The object that is returned is called "Name". Here's the information you can access through this traversal:

(from the enterprise WSDL)

Alias
FirstName
LastName
Name
Type
UserRole
UserRoleId</content>
  </entry>
  <entry>
    <title>hemm commented on Function to determine object type for whoId and whatId</title>
    <author>
      <name>hemm</name>
    </author>
    <updated>2008-04-17T23:28:47Z</updated>
    <link href="http://ideas.salesforce.com/article/show/10087660/Function_to_determine_object_type_for_whoId_and_whatId"/>
    <content type="text">You can get this pretty easily now.  The first 3 characters of every ID tell you what object it is.  Standard Objects have the same prefix in every org.  Custom Objects take a little digging. 

If you do a describeSObjects call, you can get the Prefix parameter to officially get the prefix for an object.

You can also get it easily by looking at a tab's URL.  For example, the Account tab's URL is https://na1.salesforce.com/001/o/  The prefix is 001.

Some common ones:
Lead: 00Q
Account: 001
Contact: 003
Opportunity: 006
Case: 500</content>
  </entry>
</feed>
