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
DeeZehaviDeeZehavi 

I'm having a problem quering the Event object.

Hi ,
 
I'm trying to "Select What from Event" and it doesn't work, I actually need to select all "Related To" values from scheduled events.
 
Can somebody help?
werewolfwerewolf
An Event's what is a polymorphic key, so it can point to one of many objects.  As such you can't just query the What directly (with some exceptions -- you can say Select What.Name From Event (and a couple of other things, see the polymorphic key doc link).

So it's a 2 step process.  First query what you want to query from Event, and then bucket it according to object type (which you can obtain from the first 3 chars of the ID, like opportunity is 006, case is 500, contact is 003, account is 001, etc.).  Then do a retrieve query on the specific object using the IDs you now have.
SFGeekSFGeek
Hi,

Query the Task object as events and tasks are available on the task object and specify the type as event. This should work.


Thanks
SFGeek
werewolfwerewolf
I'm afraid SFGeek's response is not correct.  Events are stored in the Event table, Tasks are stored in the Task table, and that which I wrote about the polymorphic key applies to both.