You need to sign in to do that
Don't have an account?
Querying Invitees from an Event.
Hi,
Well Im trying to get all the invitees from all the events. Ive tried the following:
public List<List<ActivityHistory>> lista {get;set;}
public List<List<ActivityHistory>> getOpen()
{
lista = new List<List<ActivityHistory>>();
SObject[] accounts = [SELECT Name,
(Select Subject, WhoId,WhatId, ActivityDate, Status, Priority, OwnerId FROM ActivityHistories) From Account];
for(SObject o : accounts){
if(o.getSObjects('ActivityHistories') != null){
List<ActivityHistory> element = (List<ActivityHistory>) o.getSObjects('ActivityHistories');
if(element != null){
lista.add(element);
}
}
}
return lista;
}
I get all the events by account and to test it Ive added 3 invitees for one of the test events. And when I run the query I only get the first invitee and no the other two. How can I get all the invitees in all the events?
Thanks in advance
Try using EventRelations instead, then:
Remember that accountId must be a string or ID that references the account you'd like to query (or change :accountId to whatever the ID of the account is in your code).
All Answers
You want this:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_eventattendee.htm
Namely, the query you're asking for is just the PRIMARY attendee of the event, not the actual attendees proper. You'll need a query like this:
(Fill in the fields you desire from each to complete the query.)
I tried this on dev console:
SELECT Id,AccountId, (SELECT Id,AccountId FROM EventAttendees) FROM EVENT Where AccountId = : accountId
and got this as an error: Unknown error parsing query
Try using EventRelations instead, then:
Remember that accountId must be a string or ID that references the account you'd like to query (or change :accountId to whatever the ID of the account is in your code).
Thats the thing Im not looking only for the invitees from only one event or account, I need the invitees from every event.
You might run into certain governor limits when trying to non-selectively query events, but you can certainly try. There's nothing stopping you from querying EventRelations or EventAttendees (it might be a versioning thing). Just remember, you're limited to 50,000 records per transaction, though.