+ Start a Discussion
SFDC coderSFDC coder 

how to get all the invitees associated to an event?

hi all,
i need to get the ids of all the contacts associated to an event.
i.e the contacts that we add into the name field.
However,when i query the whoId field,i just get the primary contact id and not all the other assciated contact ids.

can anyone please help?
Best Answer chosen by SFDC coder
EnreecoEnreeco
Try to query the EventRelation SObject (http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_eventattendee.htm), with "IsWhat = false" and "IsParent = true".
This should work.

--
May the Force.com be with you!

All Answers

EnreecoEnreeco
Try to query the EventRelation SObject (http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_eventattendee.htm), with "IsWhat = false" and "IsParent = true".
This should work.

--
May the Force.com be with you!
This was selected as the best answer
RamuRamu (Salesforce Developers) 
So basically there are 3 things you need to know about Events
1. Whoid= This consist of ID of Contact or Lead associated to the event(In UI it will be the 'Name' field)
2. Whatid = Thhis consist of ID of objects other than Contact/Lead (it will be with the name 'Relatedto' in UI)
3. EventRelation = This is a seperate object that holds the related records (Invitees in the UI).

To answer your question, you would need to query for Event and Eventrelations table to get all the information you need

Eg : select id,(select id from eventrelations) from event where id='00U9000000VuDR6'

Hope this helps !!
David Roberts 4David Roberts 4
I've been trying to add the attendees as a related list on my custom controlled apex page but can't find a syntax that works.
I get errors like: "'EventRelations' is not a valid child relationship name for entity Event "

<apex:relatedList subject="{!anEvent}" list="EventRelations">
        <apex:facet name="header">Attendees</apex:facet>
    </apex:relatedList>

where "anEvent" is my event record (public Event in controller) which succesfully returns all the fields of the event in a pageBlock.

Any ideas?