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
MycodexMycodex 

Display attendees for event

I'm trying to display a table of events and all associated attendees if it is a group event.

Code:
public List<Event> getEvents() { 
        return [SELECT id, whatID, subject, startdatetime, whoID, accountID,
            (SELECT ID, AttendeeID, Status, RespondedDate, Response FROM EventAttendees)
           FROM Event
           WHERE whatID = :ApexPages.currentPage().getParameters().get('id')
           ORDER BY startdatetime DESC];
    }

I can confirm with Apex Explorer that the SOQL statement is at least accurate and doesn't fail. Now my issue is displaying the attendees on the Visualforce page

Code:
<apex:PageBlock title="Events">
    <apex:pageBlockTable value="{!events}" var="event" >
        <apex:column value="{!event.subject}"/>
        <apex:column value="{!event.startdatetime}"/>
        <apex:column value="{!event.whoID}"/>
        <apex:column value="{!event.accountID}"/>
    </apex:PageBlockTable>
</apex:pageBlock>

 I've tried !event.EventAttendees.AttendeeID (Error: Unknown property 'ArrayList.attendeeID') and !event.AttendeeID (Error: Invalid field attendeeID for SObject Event)

The EventAttendees object is not well documented and this might just be a complete failure from the start. Any help would be appreciated.
Sam.arjSam.arj

 Use a nested datatable and set the value of it to "event.EventAttendees"
Code:
<apex:PageBlock title="Events">
<apex:pageBlockTable value="{!events}" var="event" >
<apex:column value="{!event.subject}"/>
<apex:column value="{!event.startdatetime}"/>
<apex:column value="{!event.whoID}"/>
<apex:column value="{!event.accountID}"/>
<apex:column>
<apex:DataTable value="{!events.EventAttendees}" var="attendee" >
<apex:column value="{!attendee.id}"/>
</apex:DataTable>
</apex:column>
</apex:PageBlockTable>
</apex:pageBlock>

 

Ron HessRon Hess
Sam, does that work for you when you run it ?
I get an empty list for EventAttendees even if i know they are there. will continue to look into it

Message Edited by Ron Hess on 01-09-2009 08:57 AM
Sam.arjSam.arj

No Ron, I have not tested it, but I assume it's supposed to work that way.

Ron HessRon Hess
Please file a case with support indicating that EventAttendee is always empty in a subquery.

thanks
MycodexMycodex
Thanks for the nested datatable. It worked for me despite Ron's comments. I receive the ID for the attendee in my Visualforce page. Now since Attendee can be a contact, user, or lead and the EventAttendee object does not support namePointing, how can I extract the Name of the Attendee?
Ron HessRon Hess
glad it worked!

I don't think it can be done in one query, i believe you will have to develop an apex class that has all the logic to follow the initial query with a few more queries to get the various names you require using the attendee id's

this class can then return a list of wrapper objects with all the data as properties that the page can bind to.


MPIYoriMPIYori

Not sure if this is still relevant for whoever but the following worked for me:

 

 

<apex:DataTable value="{!event.EventAttendees}" var="attendee" > <apex:column value="{!attendee.attendee.name}"/> </apex:DataTable>

 

 Sadly for some reason attendee.email only works for users but not contacts.