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
Andrew Lewis 9Andrew Lewis 9 

EventRelation to Event query question

Hi All,

I am currently tasked with reworking one of my organizations classes that counts Activity totals for users. Currently it is leaving out those who are not the main contact on the Activity. Currently the query functions as the following:

select count(id) exp1, Calendar_Year(EndDateTime) exp2, whoId, INV_Activity_Owner_Type__c exp3,  INV_Activity_Owner_Terr__c exp4
                                 from   Event where  whoId in :contactSet 
                                 group by Calendar_Year(EndDateTime),whoID ,INV_Activity_Owner_Type__c, INV_Activity_Owner_Terr__c

I am attempting to change this to use event relation as it stores all the contacts to the activity, when I try the following I recieve an error stating that it has failed to understand the relationship Event.***.

select count(id) exp1, Calendar_Year(Event.EndDateTime) exp2, RelationId, Event.INV_Activity_Owner_Type__c exp3,                     Event.INV_Activity_Owner_Terr__c exp4
                                        from   EventRelation 
                                        where  RelationId in :contactSet        

Thanks in advance for the information.