1

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

2 Answers 2

1

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.

11
  • This is not working. Here's a screen shot: i.imgur.com/coDbG.png
    – fourq
    Oct 11, 2012 at 17:46
  • 1
    It should, looks like a bug Oct 11, 2012 at 17:49
  • Owner.Type you have missed Oct 11, 2012 at 17:51
  • @MohithKumar it's in the WHERE clause
    – fourq
    Oct 11, 2012 at 18:00
  • 1
    @fourq Updated the answer and good learning.Thanks Oct 11, 2012 at 19:15
0

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.

2
  • 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, 2012 at 17:53
  • @Ralph I have updated the answer may be you would go through once .It was good learning Oct 11, 2012 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .