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
Nathan PratsNathan Prats 

SOQL Query FROM Event : How to get "Contact Title"

Hello, 

I'm trying to get the Title of the contact in this query. 
I know that events can be related to Leads or Contacts. That's probably what is causing this issue. 

SELECT CreatedBy.Name,Account_Name__c,Who.Name,CreatedDate, Who.Title
FROM Event 
WHERE CreatedBy.Profile.Name = 'Account Executives' 
AND Meeting__c = TRUE 
AND CreatedDate = today

Your help is much appreciated. 

Nathan
Srinivas SSrinivas S
Hi Nathan,

Please try as mentioned below -
[SELECT TYPEOF who WHEN Contact THEN title END FROM Event]

----
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.
Nathan PratsNathan Prats
Hi, 

I use Force.com explorer and it says that '[' is an unexpected token
Srinivas SSrinivas S
Please ignore execute as following -
SELECT TYPEOF who WHEN Contact THEN title END FROM Event

----
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.
Nathan PratsNathan Prats
I get this message when I use parenthesis

User-added image
Nathan PratsNathan Prats
I also get this message "SOQL TYPEOF expressions are not supported in this organization"