+ Start a Discussion

Getting Weird results from my Trigger

I created a simple trigger that whenever we create a "mailing" task, after the task is marked "completed" it updates the letter counter on a custom object.


trigger UpdateSentMail_02 on Task (after Insert, after update){ 

double i = 0;

// Tasks that meet criteria, and new tasks to create
Task[] qualifiedTasks = new Task[0], newTasks = new Task[0];
// Map of SD Members
   Map<Id,SD_Member__c> members = new Map<Id,SD_Member__c>();

// Find qualifying tasks
for(Task record:Trigger.new)
        if(Record.subject!=null && record.subject.contains('Print Sf Order Submitted') && record.status == 'Completed')
    // Obtain member ID values
    for(Task record:qualifiedtasks)
    // If there are any membes to query, do so.
        members.putall([select id, letter_counter__c from SD_Member__c where id in :members.keyset()]);

     for(Task record:qualifiedtasks) {
// Get the current Letter Counter value
   i = members.get(record.whatid).letter_counter__c;
// Increase the Letter Counter by 1

     update members.values();

    for(Task record:qualifiedtasks) {
    update members.values();

 When I run it one record at a time, that is, I go into SF and create each task by hand it runs fine.  But if I try and upload 500 to 1000 tasks using Excel connector or Data loader, nothing happens.


Any ideas?




There could be two reasons for this:


1) The API version of excel connector/Data loader is leass that the API version defined in Triggers' version settings. It shoild be either same or higher that the version defined in the version settings.


2) Try to upload few records for testing if it is only happening with large number of records. If yes then it is exceeding some governor limits.