What kind of result set is returned from this SOQL and can I write this inside a for loop?
[SELECT Name, Description, TYPEOF OwnerId WHEN Folder THEN Name END FROM Report]
This is a polymorphic query recently introduced by Force.com platform
Since Report ownerId can belong to Folder,organisation or user in Report Object now using TYPE OF gives flexiblity to query .Now If its folder Type then return name
same say you had one more Organisation in query since ownerId can refrence to organisation too .
Now if owner Id is Folder the query will select Name If owner ID id user the Id is returned in the query
The end result will be Report object type and yes you can have in for loop.
Check the documentation for more info
|show 2 more comments|
I try the suggested query in a SOQL query tool such as the Developer Console or SOQLExplorer and I get this error message.
SOQL TYPEOF expressions are not supported in this organization
Searching for cause leads to:
Which says this is a feature that needs to be enabled by contacting SF.