You need to sign in to do that
Don't have an account?
Manibalan Sampathkumar
SOQL Polymorphism
Hi,
Is SOQL Polymorphism generally available? Is it available in developer edition? I tried executing the following SOQL query in Developer edition, but I didn't get the contact name and email though there are contact records which matches the criteria:
SELECT Id, (SELECT TYPEOF Relation WHEN Contact THEN Name, Email END FROM EventRelations) FROM Event WHERE ActivityDateTime<=TODAY
Please let me know. Thx!
Is SOQL Polymorphism generally available? Is it available in developer edition? I tried executing the following SOQL query in Developer edition, but I didn't get the contact name and email though there are contact records which matches the criteria:
SELECT Id, (SELECT TYPEOF Relation WHEN Contact THEN Name, Email END FROM EventRelations) FROM Event WHERE ActivityDateTime<=TODAY
Please let me know. Thx!
https://developer.salesforce.com/blogs/tech-pubs/2012/09/soql-polymorphism-or-how-i-learned-to-love-the-polymorphic-relationship.html (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_typeof.htm)
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_typeof.htm
I tried the same query but didn't run. I doubt whether 'EventRelation' is accepted as TYPEOF variable in your query. Also, usually you get your related object data using 'What' variable which does not support contact object.
Also, I tried the following query in Developer edition and it didn't return anything. Do we have to open a case with SF Support to enable SOQL Polymorphism in my Dev Org?
SELECT
TYPEOF What
WHEN Account THEN Phone, NumberOfEmployees
ELSE Name, Email
END
FROM Event
Also, i tried your new query above and indeed showed be some rows returning !!!