A polymorphic lookup is, by definition, one where the SObjectType of the parent be multiple different values. That was the basis for how I compiled Polymorphic keys - definitive list?

However, a colleague stumbled across another "polymorphic" relationship via other means, namely a SOQL compile fail. Here's the query:

SELECT CreatedBy.UserType FROM CaseFeed WHERE ...

And the error:

No such column 'UserType' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

That error seems to clearly indicate this lookup is polymorphic.

Looking at the above data points, I was pretty shocked. CreatedBy is always a User, everywhere in the system. Just to sanity check, I ran the below script:


The log output was as expected:


One line of investigation clearly indicates this field is not polymorphic. The other seems to indicate it is polymorphic. I'm strongly inclined to believe the former. Is there a platform bug or Known Issue here? Or is it expected behavior?

  • Probably a bug, the documentation for the CaseFeed (developer.salesforce.com/docs/atlas.en-us.api.meta/api/…) does not make any remarks about the CreatedBy field (there's a slightly caveat for two types of feed, but seem unrelated Feb 5 '20 at 9:33
  • This issue also affects FeedItem, FeedComment, and CaseHistory.
    – Adrian Larson
    Oct 5 '20 at 14:29
  • @AdrianLarson although not explicitly mentioned why but you might want to read this and check SOQL SELECT CreatedBy.Type from CaseFeed results, which seems to confirm that CreatedById is polymorphic in these special cases because it shows up the Name object
    – Shamina
    Oct 5 '20 at 18:28

Looks like before Spring 12, CreatedBy field, on some objects, could be linked with User or SelfServiceUser object.

Found this 2010 blog post showing this screenshot:

enter image description here

SelfServiceUser is no longer available in new orgs as per doc here but since still active in older orgs, it remains polymorphic :

SelfServiceUser Represents a Contact who has been enabled to use your organization’s Self-Service portal, where he or she can obtain online support. Starting with Spring 12, the Self-Service portal isn’t available for new orgs. Existing orgs continue to have access to the Self-Service portal.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.