getSObjectType on CaseComment (00a)

The final resolution from Salesforce.com support, case number 10306483:

"When you call the getSObjectType() Apex method to an Id object to get an sObjectType from the Id, we internally call the method and try to get a Type from an entity info returned from it. And in this method call, an entity info is retrieved from a key prefix of the specified Id. However, if the key prefix points to a template entity, the method call returns null since template entities cannot reveal their entity infos. In case of CaseComment, it shares its key prefix with CaseObjectComment. So, when we try to obtain the entity info using an Id of a CaseComment, we do that through CaseObjectComment. But, since CaseObjectComment is a template entity, we cannot get its entity info. It causes the issue.

IdeaComment shares its key prefix with CaseObjectComment, too. So the same issue occurs when calling getSobjectType() Apex method to an Id of an IdeaComment."


I replicated the issue in my org.

getSObjectType has no documented limitiations in terms of which object it does or does not work for.

So it looks like a bug in SF indeed. You are going to need a workaround for this (and maybe other?) objecttypes as long as it is not resolved.

Tags:

Apex