Is the OwnerId field in the Report object a polymorphic key or not?

So the OwnerId field in the Report object can be either a reference to a Folder, Account, or User, doesn't this make it a polymorphic key? And if so, why doesn't this work?

SELECT Name, Description, OwnerId.Name FROM Report WHERE OwnerId.Type = 'Report'

This is the doc I'm referring to for polymorphic keys: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm#soql_polymorph_keys


The OwnerId is not a polymorphic key here.

The query wont work and we cannot apply that query .Also found that the ownerId is not a foreign key.

Consider the screenshot below of Report Object in eclipse enter image description here

We see above that OwnerId is not foreign key also only filterable and its not updadtable or creatable

Consider same from Event Object

enter image description here

The foreign key is who and its creatable and updatable as well hence can be used in Polymorphic queries and also can be filtered on TYPE.


A couple things. First if you're reference fields on a parent object you'll want to use the relationship name.

SELECT Owner.name FROM Report WHERE Owner.Type = 'Report'

Second, based on the report docs the owner field on a report refers only to user who created the report.

Third, Owner is a Name object, which is polymorphic. For a list of fields you can reference for any name object see the Name docs.

  • I am currently using the OwnerId to grab the folder names successfully. Screen shot: i.imgur.com/vXOet.png (This screen shot is a shot of SSMS using DBamp to create the SOQL, but regardless you can see the fields and objects taht are being used)
    – fourq
    Oct 11 '12 at 17:53
  • @Ralph I have updated the answer may be you would go through once .It was good learning Oct 11 '12 at 19:16

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.