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
isalewisalew 

Activity Counter not updating from mass emails

I built a trigger and class to count activities on leads and contacts. These counters are not updating when a user mass emails, however. Is there something I'm missing in this trigger?

 

 

trigger TP_TaskUpdateTouchPoints on Task (after delete, after insert, after undelete, after update) {

    Set<ID> ldIds = new Set<ID>();
    Set<ID> ctIds = new Set<ID>();

    //We only care about tasks linked to leads and contacts.
    String ldprefix = TP_CountsAndActivities.ldPrefix;
    String ctprefix = TP_CountsAndActivities.ctPrefix;
    
    //Add any lead or contact ids coming from the new data
    if (Trigger.new != null) {
        for (Task t : Trigger.new) {
            if (t.WhoId != null && String.valueOf(t.whoId).startsWith(ldprefix) ) {
                ldIds.add(t.whoId);
            }
            if (t.WhoId != null && String.valueOf(t.whoId).startsWith(ctPrefix)) {
                ctIds.add(t.whoId);
            }
        }
    }

    //Also add any lead or contact ids coming from the old data (deletes, moving an activity)
    if (Trigger.old != null) {
        for (Task t : Trigger.old) {
            if (t.WhoId != null && String.valueOf(t.whoId).startsWith(ldprefix) ) {
                ldIds.add(t.whoId);
            }
            if (t.WhoId != null && String.valueOf(t.whoId).startsWith(ctPrefix)) {
                ctIds.add(t.whoId);
            }

        }
    }
    
    // Only run trigger if there are records to update
    if (ldIds.size() > 0){
        TP_CountsAndActivities.updateLdCountsAndActivities(ldIds);
    }
    if (ctIds.size() > 0) {
        TP_CountsAndActivities.updateCtCountsAndActivities(ctIds);
    }
}

 

 

 

 

isalewisalew

This explains my problem:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_ignoring_operations.htm

 

So, does anybody know some apex magic that could work around this limitation?