function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manibalan SampathkumarManibalan Sampathkumar 

SOQL Polymorphism


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!
Chandra Sekhar CH N VChandra Sekhar CH N V
Yes, SOQL polymorphism is allowed in salesforce. Please follow below links for reference : (

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.
Manibalan SampathkumarManibalan Sampathkumar
Thanks Chandra Sekhar for your response! Basically, what I want to do is that I want to get contact names and their emails who have accepted the meeting invitation which I can do it without SOQL polymorphism, but I would like to know if it can be done through SOQL polymorphism. 
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?

    WHEN Account THEN Phone, NumberOfEmployees
    ELSE Name, Email
FROM Event
Chandra Sekhar CH N VChandra Sekhar CH N V
There's no concept of enabling anything here. Your queries using SOQL polymorphism will run normally.

Also,  i tried your new query above and indeed showed be some rows returning !!!
Manibalan SampathkumarManibalan Sampathkumar
Ok sure and Thanks!