• The Aquinois
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I would like to great everyone there. This is my very first post in this forum. I am facing a real problem. I am responsible for developing on Salesforce for an NGO and begin using Salesforce for 8 months. So I am realy new.

I have learned about the system limitations, such as governor limits. Apex best practice, avoid SOQL queries or DMl code in for/while loop.

So, I try to do my best. but, I am facing a real probleme that I have to explain a litle bit. For an NGO, it is import to report monthly to the donors. It comes to my boss this idea to automatically generate indicators values as the projects progress. as a matter of fact, every single time a user insert/update/delete a record, the related indicator must be update. so far, so good. the problem comes when we consider that the organization produces a very high quantity of informations. so, it's impossible to insert then one by oneusing forms. So we need to implement mass Edit/update or import with CSV file. Which is good. There is alot of indicators, so, when an action trigger on an object, it is very important that the related indicator be created or updated for the precise month. Thus, I use the following code 

A) Utility Class I use to handle some functions that I need for all trigger handlers
public class UtilitiesRecordTrack {
	   
   Public static double getPercent(integer numerateur, integer denominateur)
   {
       return (double) denominateur > 0 ? (( (double) numerateur / (double) denominateur ) * 100) : 0;
   }
    
   public static ID getProjectID(String projectName)
    {
        ID projectId = [SELECT Id FROM Project_1__c WHERE Name = : projectName].Id;
        return projectId;
    }
    
    public static List<Indicator_1__c> getIndicator(String indicatorFullName, String projectName)
    {
        Indicator_1__c[] indicator = [SELECT Id, Indicator_Full_Name__c, Related_Project__c
                                                 FROM Indicator_1__c 
                                                 WHERE Indicator_Full_Name__c =: indicatorFullName
                                                 AND Related_Project__c =: getProjectID(projectName)
                                     ];
        return indicator;
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(ID indicatorId, Decimal monthNumber, ID operationId)
    {
        return [SELECT Id FROM Track_Indicator__c WHERE Indicator_Id__c = 
                                                  :indicatorId
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(String indicatorFullName, Decimal monthNumber, ID operationId, String projectName)
    {
        return [SELECT Id, Indicator_Id__r.Indicator_Full_Name__c, Indicator_Id__r.Related_Project__c, Indicator_Id__c FROM Track_Indicator__c
                                                   WHERE Indicator_Id__r.Indicator_Full_Name__c = :indicatorFullName
                                                   AND Indicator_Id__r.Related_Project__c = :[SELECT Id FROM Project_1__c WHERE Name =:projectName]
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }

    public static void recordOrUpdate(List<Track_Indicator__c> trackToUpdate, Decimal actual, Date d, ID i, ID o)
    {
            System.debug('Function clalled');
           if(trackToUpdate.size() > 0)
           {
              trackToUpdate[0].Actual__c = actual;
              trackToUpdate[0].Date__c =  d;
              update trackToUpdate;
              System.debug('Updated');
            }else{
                 Track_Indicator__c newTrack = new Track_Indicator__c();
                 newTrack.Actual__c = actual;
                 newTrack.Date__c = d;
                 newTrack.Indicator_Id__c = i;
                 newTrack.Operation_Name__c = o;
                 insert newTrack;
                 System.debug('Inserted');
             }
     }
    
    public static void UpdateTrack(Track_Indicator__c trackToUpdate, Decimal actual, Date d, ID o)
    {
       trackToUpdate.Actual__c = actual;
       trackToUpdate.Date__c =  d;
       trackToUpdate.Operation_Name__c = o;
       update trackToUpdate;
       System.debug('Updated');
    }
    
     public static void TrackCreate(Decimal actual, Date d, ID i, ID o){
       Track_Indicator__c t = new Track_Indicator__c();
        t.Actual__c = actual;
        t.Date__c = d;
        t.Indicator_Id__c = i;
        t.Operation_Name__c = o;
        insert t;
    }
}


This is a trigger handler class
 
public class RecordTrackOnSongHelper {
    public static double getTotalSongWrintenByschool(Decimal month , ID operation)
    {
        return [SELECT Id FROM Song__c WHERE Month_Number__c = :month AND Operation_Name__c = :operation].size();
    }
    
    public static void recordTrack(List<Song__c> newRecords, String indicatorFullName, String projectName){
        
      
        if(indicatorFullName == '# of songs written by participating schools'
                                && projectName == 'Music Heals International')
        {
             //List<Track_Indicator__c> trackToInsertCaseStudy = new List<Track_Indicator__c>() ;
             //List<Track_Indicator__c> trackToUpdateCaseStudy = new List<Track_Indicator__c>() ;
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Song__c s : newRecords)
                 {
                         actual = (Decimal) getTotalSongWrintenByschool(s.Month_Number__c , s.Operation_Name__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, s.Month_Number__c, s.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked, actual, s.Date__c, Indicator[0].Id, s.Operation_Name__c);
                 }

             }
        }

    }
}

But see it for activities:
 
public class RecordTrackOnActivityHelper {
    
    public static double  getTotalActivityOn(Decimal month, ID operation, String activityType, ID projectId)
    {
          return [SELECT Id FROM Activity_1__c WHERE 
                                               Activity_Type__c = :activityType
                                               AND Project_Name__c =:projectId
                                               AND Month_Number__c =: month
                                               AND Operation_Name__c =: operation].size();
    }
    
    public static double getTotalCommunityMemberSensitized(Decimal month, ID operation, String activityType, ID project)
    {
        return double.valueOf([SELECT SUM(Number_Of_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :activityType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : project
                                                     ANd Operation_Name__c =: operation][0].get('expr0'));
    }
    
    public static double getTotalTotalConertHeledBy(Decimal month, ID operation, String activityType, ID pr){
        return [SELECT Id FROM Activity_1__c WHERE Activity_Type__c =:activityType
                                             AND Month_Number__c = :month
                                             AND Project_Name__c = : pr
                                             AND Operation_Name__c =: operation
               ].size();
    }
    
    
    public static Double getTotalBoys(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Male_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = : actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
    public static Double getTotalGirls(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Female_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
 
    public static void recordTrack(List<Activity_1__c> newRecords, String indicatorFullName, String projectName){
        
              
        if(indicatorFullName == 'Number  extracurricular activities'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Extra Curricula Activity'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        
        if(indicatorFullName == 'Number of meetings with parents'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Meeting With Parent'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
      
        if(indicatorFullName == '# of hygiene club meeting carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'hygiene club meeting carried out -(WASH)'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        if(indicatorFullName == '# of sensitization campaigns carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'sensitization campaigns'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }
                 
             }
        }
}

Trigger:
 
trigger RecordRelatedTrackIndicatorOnActivity on Activity_1__c (after insert, after update) {
    if(Trigger.isInsert)
    {
	  RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
      
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
  

     
    }
 	
    if(Trigger.isUpdate)
    {
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
        
        
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
    }
}

magine these functions being calling for every row in a CSV file or comming from mass update. even two rows, the governor limit exceipt raised.

If someone can help, I will realy appreciate that. I tried Map, but same reallity.
 
I would like to great everyone there. This is my very first post in this forum. I am facing a real problem. I am responsible for developing on Salesforce for an NGO and begin using Salesforce for 8 months. So I am realy new.

I have learned about the system limitations, such as governor limits. Apex best practice, avoid SOQL queries or DMl code in for/while loop.

So, I try to do my best. but, I am facing a real probleme that I have to explain a litle bit. For an NGO, it is import to report monthly to the donors. It comes to my boss this idea to automatically generate indicators values as the projects progress. as a matter of fact, every single time a user insert/update/delete a record, the related indicator must be update. so far, so good. the problem comes when we consider that the organization produces a very high quantity of informations. so, it's impossible to insert then one by oneusing forms. So we need to implement mass Edit/update or import with CSV file. Which is good. There is alot of indicators, so, when an action trigger on an object, it is very important that the related indicator be created or updated for the precise month. Thus, I use the following code 

A) Utility Class I use to handle some functions that I need for all trigger handlers
public class UtilitiesRecordTrack {
	   
   Public static double getPercent(integer numerateur, integer denominateur)
   {
       return (double) denominateur > 0 ? (( (double) numerateur / (double) denominateur ) * 100) : 0;
   }
    
   public static ID getProjectID(String projectName)
    {
        ID projectId = [SELECT Id FROM Project_1__c WHERE Name = : projectName].Id;
        return projectId;
    }
    
    public static List<Indicator_1__c> getIndicator(String indicatorFullName, String projectName)
    {
        Indicator_1__c[] indicator = [SELECT Id, Indicator_Full_Name__c, Related_Project__c
                                                 FROM Indicator_1__c 
                                                 WHERE Indicator_Full_Name__c =: indicatorFullName
                                                 AND Related_Project__c =: getProjectID(projectName)
                                     ];
        return indicator;
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(ID indicatorId, Decimal monthNumber, ID operationId)
    {
        return [SELECT Id FROM Track_Indicator__c WHERE Indicator_Id__c = 
                                                  :indicatorId
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(String indicatorFullName, Decimal monthNumber, ID operationId, String projectName)
    {
        return [SELECT Id, Indicator_Id__r.Indicator_Full_Name__c, Indicator_Id__r.Related_Project__c, Indicator_Id__c FROM Track_Indicator__c
                                                   WHERE Indicator_Id__r.Indicator_Full_Name__c = :indicatorFullName
                                                   AND Indicator_Id__r.Related_Project__c = :[SELECT Id FROM Project_1__c WHERE Name =:projectName]
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }

    public static void recordOrUpdate(List<Track_Indicator__c> trackToUpdate, Decimal actual, Date d, ID i, ID o)
    {
            System.debug('Function clalled');
           if(trackToUpdate.size() > 0)
           {
              trackToUpdate[0].Actual__c = actual;
              trackToUpdate[0].Date__c =  d;
              update trackToUpdate;
              System.debug('Updated');
            }else{
                 Track_Indicator__c newTrack = new Track_Indicator__c();
                 newTrack.Actual__c = actual;
                 newTrack.Date__c = d;
                 newTrack.Indicator_Id__c = i;
                 newTrack.Operation_Name__c = o;
                 insert newTrack;
                 System.debug('Inserted');
             }
     }
    
    public static void UpdateTrack(Track_Indicator__c trackToUpdate, Decimal actual, Date d, ID o)
    {
       trackToUpdate.Actual__c = actual;
       trackToUpdate.Date__c =  d;
       trackToUpdate.Operation_Name__c = o;
       update trackToUpdate;
       System.debug('Updated');
    }
    
     public static void TrackCreate(Decimal actual, Date d, ID i, ID o){
       Track_Indicator__c t = new Track_Indicator__c();
        t.Actual__c = actual;
        t.Date__c = d;
        t.Indicator_Id__c = i;
        t.Operation_Name__c = o;
        insert t;
    }
}


This is a trigger handler class
 
public class RecordTrackOnSongHelper {
    public static double getTotalSongWrintenByschool(Decimal month , ID operation)
    {
        return [SELECT Id FROM Song__c WHERE Month_Number__c = :month AND Operation_Name__c = :operation].size();
    }
    
    public static void recordTrack(List<Song__c> newRecords, String indicatorFullName, String projectName){
        
      
        if(indicatorFullName == '# of songs written by participating schools'
                                && projectName == 'Music Heals International')
        {
             //List<Track_Indicator__c> trackToInsertCaseStudy = new List<Track_Indicator__c>() ;
             //List<Track_Indicator__c> trackToUpdateCaseStudy = new List<Track_Indicator__c>() ;
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Song__c s : newRecords)
                 {
                         actual = (Decimal) getTotalSongWrintenByschool(s.Month_Number__c , s.Operation_Name__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, s.Month_Number__c, s.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked, actual, s.Date__c, Indicator[0].Id, s.Operation_Name__c);
                 }

             }
        }

    }
}

But see it for activities:
 
public class RecordTrackOnActivityHelper {
    
    public static double  getTotalActivityOn(Decimal month, ID operation, String activityType, ID projectId)
    {
          return [SELECT Id FROM Activity_1__c WHERE 
                                               Activity_Type__c = :activityType
                                               AND Project_Name__c =:projectId
                                               AND Month_Number__c =: month
                                               AND Operation_Name__c =: operation].size();
    }
    
    public static double getTotalCommunityMemberSensitized(Decimal month, ID operation, String activityType, ID project)
    {
        return double.valueOf([SELECT SUM(Number_Of_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :activityType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : project
                                                     ANd Operation_Name__c =: operation][0].get('expr0'));
    }
    
    public static double getTotalTotalConertHeledBy(Decimal month, ID operation, String activityType, ID pr){
        return [SELECT Id FROM Activity_1__c WHERE Activity_Type__c =:activityType
                                             AND Month_Number__c = :month
                                             AND Project_Name__c = : pr
                                             AND Operation_Name__c =: operation
               ].size();
    }
    
    
    public static Double getTotalBoys(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Male_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = : actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
    public static Double getTotalGirls(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Female_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
 
    public static void recordTrack(List<Activity_1__c> newRecords, String indicatorFullName, String projectName){
        
              
        if(indicatorFullName == 'Number  extracurricular activities'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Extra Curricula Activity'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        
        if(indicatorFullName == 'Number of meetings with parents'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Meeting With Parent'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
      
        if(indicatorFullName == '# of hygiene club meeting carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'hygiene club meeting carried out -(WASH)'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        if(indicatorFullName == '# of sensitization campaigns carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'sensitization campaigns'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }
                 
             }
        }
}

Trigger:
 
trigger RecordRelatedTrackIndicatorOnActivity on Activity_1__c (after insert, after update) {
    if(Trigger.isInsert)
    {
	  RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
      
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
  

     
    }
 	
    if(Trigger.isUpdate)
    {
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
        
        
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
    }
}

magine these functions being calling for every row in a CSV file or comming from mass update. even two rows, the governor limit exceipt raised.

If someone can help, I will realy appreciate that. I tried Map, but same reallity.