+ Start a Discussion
Ken sfdc1Ken sfdc1 

Rollup summary for lookup relationships my custom objects but having an error

trigger CountSpeakerEvaluationsnew on Speaker_Evaluation_AEGR__c(after insert, after delete, after undelete) {

    List<id> accIdList = new List<id>();
    if(Trigger.isInsert || Trigger.isUndelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.new){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    if(Trigger.isDelete){
        For(Speaker_Evaluation_AEGR__c con1 : Trigger.old){
            accIdList.add(con1.Medical_Event_vod__c.id);
        }
    }
    List<Account> accUpdateList = new List<Account>();
    For(Medical_Event_vod__c acc : [SELECT  No_of_Speaker_Evaluations__c,(SELECT id FROM Speaker_Evaluations__r) FROM Medical_Event_vod__c WHERE id =: accIdList]){
        acc.No_of_Speaker_Evaluations__c = acc.Speaker_Evaluations__c.size();
        accUpdateList.add(acc);
    }
    try{
        update accUpdateList;
    }Catch(Exception e){
        System.debug('Exception :'+e.getMessage());
    }
}


Error: Compile Error: Invalid foreign key relationship: Speaker_Evaluation_AEGR__c.Medical_Event_vod__c at line 6 column 27