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
BdavisBOKFBdavisBOKF 

AccountID not available on Event during delete trigger Winter 13

I have a trigger that is updating a field to track the last event date.   This code currently works in Summer 12 and worked last week in Winter 13.We only have basic support so the help desk was not helpful.  This is in spite of the fact that this is clearly a Winter 13 release issue.

 

Next post has the debug log.

 

 

trigger EventInsertUpdate on Event (before insert, before update, after insert, after update, after delete) {

     if(! trigger.isDelete && trigger.IsBefore){
        for(Event e : Trigger.new) {
            // If the Event Type (Reporting) field does not contain
            // the picklist value of the field Type, populate it with that 
            // picklist value from Type.        
            
            if(e.Event_Type_Reporting__c != e.Type && Trigger.IsBefore) {   
                e.Event_Type_Reporting__c = e.Type;
            }
        }
     }
    // Before triggers can just get out.  The rest is after only.
    if(trigger.IsBefore) return;
    // Put account ids for deleted records in array.
    List <Id> acctsIDList = new List<Id>();
    if(trigger.isDelete){
       
        for(Event e : Trigger.old){
         System.Debug('This is the event in delete' + [Select AccountID, ID, ActivityDateTime From Event Where ID = :e.ID ALL ROWS]);
            if(e.AccountId != null){
                acctsIDList.add(e.AccountId);
            }
        }   
    } else {
        for(Event e : Trigger.new){
            if(e.AccountId != null){
                acctsIDList.add(e.AccountId);
            }
        }
    }
    System.Debug('The acctsIDList size is:' + acctsIDList.size());
    if(acctsIDList.isEmpty()) return;       
    // Now update the LastEventDate for all accounts if necessary
    Map<Id, Account> acctsMap = new Map<Id, Account>([SELECT Id, OwnerId, LastEventDate__c,
                                                            Owner_Last_Activity_Date__c
                                                        FROM Account 
                                                        WHERE Id in :acctsIdList]);
    
    System.Debug('The acctsMap size is:' + acctsMap.size());
    if(acctsMap.values().size() > 0) AccountUtil.UpdateActivityDates(acctsMap);
}

 

 

 
BdavisBOKFBdavisBOKF

Her is the debug log

 

18.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
15:05:18.372 (372132000)|EXECUTION_STARTED
15:05:18.372 (372179000)|CODE_UNIT_STARTED|[EXTERNAL]|01q70000000L0Cg|EventInsertUpdate on Event trigger event AfterDelete for [00UV00000019BzN]
15:05:18.373 (373564000)|SYSTEM_CONSTRUCTOR_ENTRY|[26]|<init>()
15:05:18.373 (373610000)|SYSTEM_CONSTRUCTOR_EXIT|[26]|<init>()
15:05:18.373 (373768000)|SYSTEM_METHOD_ENTRY|[29]|LIST<Event>.iterator()
15:05:18.374 (374145000)|SYSTEM_METHOD_EXIT|[29]|LIST<Event>.iterator()
15:05:18.374 (374173000)|SYSTEM_METHOD_ENTRY|[29]|system.ListIterator.hasNext()
15:05:18.374 (374202000)|SYSTEM_METHOD_EXIT|[29]|system.ListIterator.hasNext()
15:05:18.374 (374523000)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|select AccountID, ID, ActivityDateTime from Event where ID = :tmpVar1 all rows
15:05:18.378 (378563000)|SOQL_EXECUTE_END|[30]|Rows:1
15:05:18.378 (378690000)|SYSTEM_METHOD_ENTRY|[30]|String.valueOf(Object)
15:05:18.378 (378762000)|SYSTEM_METHOD_EXIT|[30]|String.valueOf(Object)
15:05:18.378 (378795000)|SYSTEM_METHOD_ENTRY|[30]|System.debug(ANY)
15:05:18.378 (378802000)|USER_DEBUG|[30]|DEBUG|This is the event in delete(Event:{ActivityDateTime=2012-11-29 21:00:00, Id=00UV00000019BzNMAU})
15:05:18.378 (378808000)|SYSTEM_METHOD_EXIT|[30]|System.debug(ANY)
15:05:18.378 (378873000)|SYSTEM_METHOD_ENTRY|[29]|system.ListIterator.hasNext()
15:05:18.378 (378898000)|SYSTEM_METHOD_EXIT|[29]|system.ListIterator.hasNext()
15:05:18.378 (378942000)|SYSTEM_METHOD_ENTRY|[42]|LIST<Id>.size()
15:05:18.379 (379001000)|SYSTEM_METHOD_EXIT|[42]|LIST<Id>.size()
15:05:18.379 (379014000)|SYSTEM_METHOD_ENTRY|[42]|String.valueOf(Object)
15:05:18.379 (379023000)|SYSTEM_METHOD_EXIT|[42]|String.valueOf(Object)
15:05:18.379 (379032000)|SYSTEM_METHOD_ENTRY|[42]|System.debug(ANY)
15:05:18.379 (379036000)|USER_DEBUG|[42]|DEBUG|The acctsIDList size is:0
15:05:18.379 (379041000)|SYSTEM_METHOD_EXIT|[42]|System.debug(ANY)
15:05:18.379 (379055000)|SYSTEM_METHOD_ENTRY|[43]|LIST<Id>.isEmpty()
15:05:18.379 (379083000)|SYSTEM_METHOD_EXIT|[43]|LIST<Id>.isEmpty()
15:05:18.967 (379117000)|CUMULATIVE_LIMIT_USAGE
15:05:18.967|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 1 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 7 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

15:05:18.967|CUMULATIVE_LIMIT_USAGE_END

15:05:18.379 (379166000)|CODE_UNIT_FINISHED|EventInsertUpdate on Event trigger event AfterDelete for [00UV00000019BzN]
15:05:18.379 (379174000)|EXECUTION_FINISHED