+ Start a Discussion
Anthony PiaiaAnthony Piaia 

after insert, after update triggers

Hello, I need some help with a couple triggers i'm having issues with.  I am somewhat new to triggers and i created and After update trigger that inserts a list when an opportunity is updated if the list = 0.  The problem i'm having is that another trigger might be causing my trigger some issues.  We have a database feeding into salesforce using a boomi process and accounts are not being updated or failing because of the 2 triggers.  Below is the error:

SF_ERROR: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
OBJ: Applicant__c - ApplicantDataWriting: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 006F000000JBTpEIAX; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, applicationchecklistUpdate: execution of AfterUpdate

caused by: System.DmlException: Insert failed. First exception on row 0 with id a0sF0000003fQgQIAU; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Trigger.applicationchecklistUpdate: line 202, column 1: []

Trigger.ApplicantDataWriting: line 266, column 1

My trigger is an after update trigger which inserts a list an an object if it's = to 0 and the other triger is an after insert, after update trigger which converts leads to opportunities, updates accounts, opportunities and create new opportunities based on a boomi process we have which feeds from our database to boomi.

I did not have room to post the code but i can after i sumit the question.

Any help is appreciated.
Anthony PiaiaAnthony Piaia
trigger applicationchecklistUpdate on Opportunity (after update) 
{
    Application_Check_List__c acl = new Application_Check_List__c();        
    List<Application_Check_List__c> newApplicationList = new List<Application_Check_List__c>();           
    List<Opportunity> newOpportunityList = new List <Opportunity>();        
  for(Opportunity opp : trigger.new)
  
        {   
            if(opp.RecordTypeId == '012A0000000SDYt' && trigger.isUpdate && opp.Total_Application_Checklist_Items__c == 0)      
            {           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'       
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security' || opp.Program_of_Study__c == 'BA Comm Arts' || opp.Program_of_Study__c == 'BA IS'          
                || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online' || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')           
                            
            {           
                acl = new Application_Check_List__c(Subject__c = 'Application Fee', Opportunity__c = opp.id, type__c = 'Automatic');            
                newApplicationList.add(acl);            
            }               
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'   
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security' || opp.Program_of_Study__c == 'BA Comm Arts'            
                || opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'           
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {   
                acl=new Application_Check_List__c(Subject__c = 'Holds', Opportunity__c = opp.id, type__c = 'Automatic');            
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Funding Plan', Opportunity__c = opp.id, type__c = 'Automatic');         
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'FL Residency Proof 1', Opportunity__c = opp.id, type__c = 'Automatic');         
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'FL Residency Proof 2', Opportunity__c = opp.id, type__c = 'Automatic');
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Official UGRD Transcripts', Opportunity__c = opp.id, type__c = 'Automatic');            
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Official GRAD Transcripts', Opportunity__c = opp.id, type__c = 'Automatic');            
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Official Transcripts Translation', Opportunity__c = opp.id, type__c = 'Automatic');         
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Proof of Degree', Opportunity__c = opp.id, type__c = 'Automatic');          
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'HCMBA Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'MSGSC Online')         
            {           
                acl=new Application_Check_List__c(Subject__c = 'GRE/GMAT Scores', Opportunity__c = opp.id, type__c = 'Automatic');      
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security' || opp.Program_of_Study__c == 'BA Comm Arts'            
                || opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'           
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {           
                acl=new Application_Check_List__c(Subject__c = 'TOEFL / IELTS Scores', Opportunity__c = opp.id, type__c = 'Automatic');         
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Resume', Opportunity__c = opp.id, type__c = 'Automatic');           
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'MSRE Online' || opp.Program_of_Study__c == 'MIB Online' || opp.Program_of_Study__c == 'HCMBA Online'           
                || opp.Program_of_Study__c == 'Cert. GCHM' || opp.Program_of_Study__c == 'MSCI Online' || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'             
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Statement of Purpose', Opportunity__c = opp.id, type__c = 'Automatic');         
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'HCMBA Online' || opp.Program_of_Study__c == '' || opp.Program_of_Study__c == 'MSCI Online'             
                || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'            
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Letter of Recommendation 1', Opportunity__c = opp.id, type__c = 'Automatic');           
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSHRM Online' || opp.Program_of_Study__c == 'HCMBA Online' || opp.Program_of_Study__c == '' || opp.Program_of_Study__c == 'MSCI Online'             
                || opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSGSC Online'            
                || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Letter of Recommendation 2', Opportunity__c = opp.id, type__c = 'Automatic');           
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MS Engineering Mgmt' || opp.Program_of_Study__c == 'MS Network Security')           
            {           
                acl=new Application_Check_List__c(Subject__c = 'Letter of Recommendation 3', Opportunity__c = opp.id, type__c = 'Automatic');           
                newApplicationList.add(acl);            
            }           
            if (opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSCI Online')           
            {           
                acl=new Application_Check_List__c(Subject__c = 'Letter of Eligibility for Teacher Certification', Opportunity__c = opp.id, type__c = 'Automatic');      
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSCI Online')           
            {           
                acl=new Application_Check_List__c(Subject__c = 'Teacher Certification', Opportunity__c = opp.id, type__c = 'Automatic');        
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'MSSE Online' || opp.Program_of_Study__c == 'MSCI Online')           
            {           
                acl=new Application_Check_List__c(Subject__c = 'TCE Scores ', Opportunity__c = opp.id, type__c = 'Automatic');      
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'BA Comm Arts'|| opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'          
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {           
                acl=new Application_Check_List__c(Subject__c = 'HS Transcripts / GED Scores & Certificate', Opportunity__c = opp.id, type__c = 'Automatic');        
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'BA Comm Arts'|| opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'          
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {           
                acl=new Application_Check_List__c(Subject__c = 'College Transcripts', Opportunity__c = opp.id, type__c = 'Automatic');      
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'BA Comm Arts'|| opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'          
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {           
                acl=new Application_Check_List__c(Subject__c = 'International Transcripts Translation & Course Evaluation', Opportunity__c = opp.id, type__c = 'Automatic');        
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'BA Comm Arts'|| opp.Program_of_Study__c == 'BA IS' || opp.Program_of_Study__c == 'BA Psych' || opp.Program_of_Study__c == 'BBA Online'          
                || opp.Program_of_Study__c == 'BS CJ'|| opp.Program_of_Study__c == 'BS Early Child Dev' || opp.Program_of_Study__c == 'B Health Services Admin'             
                || opp.Program_of_Study__c == 'BS Hospitality' || opp.Program_of_Study__c == 'BS Rec and Sport Mgmt')               
            {           
                acl=new Application_Check_List__c(Subject__c = 'SAT / ACT Scores', Opportunity__c = opp.id, type__c = 'Automatic');     
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'MIB Online')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Prereq: Accounting', Opportunity__c = opp.id, type__c = 'Automatic');       
                newApplicationList.add(acl);    
            }           
            if (opp.Program_of_Study__c == 'MIB Online')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Prereq: Marketing', Opportunity__c = opp.id, type__c = 'Automatic');        
                newApplicationList.add(acl);        
            }           
            if (opp.Program_of_Study__c == 'MIB Online')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Prereq: Finance', Opportunity__c = opp.id, type__c = 'Automatic');  
                newApplicationList.add(acl);    
            }           
            if (opp.Program_of_Study__c == 'MIB Online')            
            {           
                acl=new Application_Check_List__c(Subject__c = 'Prereq: Operations Mgmt. OR Statistics', Opportunity__c = opp.id, type__c = 'Automatic');       
                newApplicationList.add(acl);        
            }
            if (opp.Program_of_Study__c == 'MSHRM Online')          
            {           
                acl=new Application_Check_List__c(Subject__c = 'Admission Interview', Opportunity__c = opp.id, type__c = 'Automatic');      
                newApplicationList.add(acl);        
            }
            if (opp.Program_of_Study__c == 'MSHRM Online')          
            {           
                acl=new Application_Check_List__c(Subject__c = 'Critical Thinking Assessment', Opportunity__c = opp.id, type__c = 'Automatic');     
                newApplicationList.add(acl);
            }
        }
        if(newApplicationList <> null) insert newApplicationList;             
    }
}

Anthony PiaiaAnthony Piaia
trigger ApplicantDataWriting on Applicant__c (after insert, after update) 
{
  List<String> accIds = new List<String>();
  List<String> oppIds = new List<String>();
  List<String> leadIds = new List<String>();
  
  for(Applicant__c a : trigger.new)// If the Account, Opportunity and Lead Ids exist save it in a variable (For Updates)
  {
    if(a.Account_Id__c != null)accIds.add(a.Account_Id__c);
    if(a.Opportunity_Id__c != null)oppIds.add(a.Opportunity_Id__c);
    if(a.Lead_Id__c != null && a.Account_Id__c == null && a.Opportunity_Id__c == null)leadIds.add(a.Lead_Id__c);
  } 
  
  // look for the account information
  List<Account> accList = [select Id, 
                  Panther_Id_Student__pc, 
                  FirstName, 
                  LastName, 
                  PersonBirthdate,
                  PersonMailingStreet, 
                  PersonMailingCity, 
                  PersonMailingState, 
                  PersonMailingPostalCode,
                  Campus_Email__pc, 
                  HOB_Email__pc, 
                  Other_Email__pc, 
                  Parent_Email__pc,
                  PersonHomePhone,
                  PersonMobilePhone,
                  PersonOtherPhone,
                  PersonEmail,
                  Phone,
                  SAT__pc, 
                  SAT_Writing__pc, 
                  SAT_Verb__pc, 
                  SAT_Math__pc, 
                  HSOV_Units__pc, 
                  UGOV_Units__pc, 
                  GPA_HS__pc, 
                  GPA_UG__pc, 
                  ACT__pc, 
                  ACT_Read__pc, 
                  ACT_Math__pc, 
                  ACT_ENG__pc,
                  Admit_Type__pc,
                  Admit_Type_Description__pc,
                  Image_Now_Link__pc,
                  RecordTypeId
                 from Account
                where Id IN :accIds];
                
  
  // look for the opportunity informaton    
  List<Opportunity> oppList = [select Id, StageName, Application_Status__c, Application_Status_Code__c, Application_Status_Detail__c, Application_Status_Detail_Code__c,
                    Admit_Term__c, Admit_Term_Code__c, Residency__c, Residency_Code__c, Academic_Plan__c, Application_Id__c, Sub_Plan__c, Stop_Updating_Stage__c,
                    Generated_From__c, Application_Fee_Status__c, Application_Fee_Paid__c, Application_Fee_Date__c, Plan_Changed__c,Plan_Changed_Date__c,
                    Enrolled_Orientation_Course__c, Enrolled_Credit_Course__c
                   from Opportunity
                  where Id IN :oppIds];
                    
  //look for the lead information                
  List<Lead> leadList = [select Id, Status, Email, Email_2__c, OwnerId, Description
              from Lead
              where Id IN :leadIds];
                    
              
  List<Account> accToInsert = new List<Account>();
  
  Map<String, Account> pIdsWithAccounts = new Map<String, Account>();
  
  Account tempAcc;
  
  List<Opportunity> oppToInsert = new List<Opportunity>();
  Opportunity tempOpp;

  for(Applicant__c ap : trigger.new)
  {
    if(ap.Account_Id__c != null)  // verify that the appicant have a account
    {
      for(Account a : accList)
      {
        if(a.Id != ap.Account_Id__c)continue; //verify if there's an existing account; assign the new applicant values to the account 
        a.Panther_Id_Student__pc = ap.Panther_Id__c;
        a.FirstName = ap.First_Name__c;
        a.LastName = ap.Last_Name__c;
        a.PersonBirthdate = ap.Birthdate__c;
        a.PersonMailingStreet = ap.Street__c;
        a.PersonMailingCity = ap.City__c;
        a.PersonMailingState = ap.State__c;
        a.PersonMailingPostalCode = ap.PostalCode__c;
        a.Campus_Email__pc = ap.Email_2__c;
        a.HOB_Email__pc = ap.HOB_Email__c;
        a.Other_Email__pc = ap.Other_Email__c;
        a.Parent_Email__pc = ap.Parent_Email__c;
        a.PersonHomePhone = ap.Home_Phone__c;
        a.PersonMobilePhone = ap.Mobile__c;
        a.PersonOtherPhone = ap.Other_Phone__c;
        if(a.PersonEmail == null) a.PersonEmail = ap.PersonEmail__c;
        if(ap.Phone__c!= null) a.phone = ap.Phone__c;
        a.SAT__pc = ap.SAT__c;
        a.SAT_Writing__pc = ap.SAT_Write__c;
        a.SAT_Verb__pc = ap.SAT_Verb__c;
        a.SAT_Math__pc = ap.SAT_Math__c;
        a.HSOV_Units__pc = ap.HSOV_Units__c;
        a.UGOV_Units__pc = ap.UGOV_Units__c;
        a.GPA_HS__pc = ap.GPA_HS__c;
        a.GPA_UG__pc = ap.GPA_UG__c;
        a.ACT__pc = ap.ACT__c;
        a.ACT_Read__pc = ap.ACT_Read__c;
        a.ACT_Math__pc = ap.ACT_Math__c;
        a.ACT_ENG__pc = ap.ACT_ENG__c;
        a.Admit_Type__pc =   ap.Admit_Type__c;
        a.Admit_Type_Description__pc = ap.Admit_Type_Description__c;
        a.Image_Now_Link__pc = ap.Image_Now_Link__c;                  
      }
    }
    else if(ap.Account_Id__c == null && ap.Lead_Id__c == null) // verify if applincant don't have an account nor Lead assigned
    {
      if(pIdsWithAccounts.containsKey(ap.Panther_Id__c))//verify if there's an account in SF with the same panther id, update the values of the account with the new applicant values 
      {
        tempAcc = pIdsWithAccounts.get(ap.Panther_Id__c);
        tempAcc.Panther_Id_Student__pc = ap.Panther_Id__c;
        tempAcc.FirstName = ap.First_Name__c;
        tempAcc.LastName = ap.Last_Name__c;
        tempAcc.PersonBirthdate = ap.Birthdate__c;
        tempAcc.PersonMailingStreet = ap.Street__c;
        tempAcc.PersonMailingCity = ap.City__c;
        tempAcc.PersonMailingState = ap.State__c;
        tempAcc.PersonMailingPostalCode = ap.PostalCode__c;
        tempAcc.Campus_Email__pc = ap.Email_2__c;
        tempAcc.HOB_Email__pc = ap.HOB_Email__c;
        tempAcc.Other_Email__pc = ap.Other_Email__c;
        tempAcc.Parent_Email__pc = ap.Parent_Email__c;
        tempAcc.PersonHomePhone = ap.Home_Phone__c;
        tempAcc.PersonMobilePhone = ap.Mobile__c;
        tempAcc.PersonOtherPhone = ap.Other_Phone__c;
        tempAcc.PersonEmail = ap.PersonEmail__c;
        if(ap.Phone__c != null) tempAcc.phone = ap.Phone__c;
        tempAcc.SAT__pc = ap.SAT__c;
        tempAcc.SAT_Writing__pc = ap.SAT_Write__c;
        tempAcc.SAT_Verb__pc = ap.SAT_Verb__c;
        tempAcc.SAT_Math__pc = ap.SAT_Math__c;
        tempAcc.HSOV_Units__pc = ap.HSOV_Units__c;
        tempAcc.UGOV_Units__pc = ap.UGOV_Units__c;
        tempAcc.GPA_HS__pc = ap.GPA_HS__c;
        tempAcc.GPA_UG__pc = ap.GPA_UG__c;
        tempAcc.ACT__pc = ap.ACT__c;
        tempAcc.ACT_Read__pc = ap.ACT_Read__c;
        tempAcc.ACT_Math__pc = ap.ACT_Math__c;
        tempAcc.ACT_ENG__pc = ap.ACT_ENG__c;
        tempAcc.Admit_Type__pc = ap.Admit_Type__c;
        tempAcc.Admit_Type_Description__pc = ap.Admit_Type_Description__c;  
        tempAcc.Image_Now_Link__pc = ap.Image_Now_Link__c;
        tempAcc.OwnerId = '005F0000001zni0';
        tempAcc.RecordTypeId = '012A0000000oTZQ';
      }
      else // there's no account with the panther id, create the account
      {
        tempAcc = new Account(  Panther_Id_Student__pc = ap.Panther_Id__c,
                    FirstName = ap.First_Name__c,
                    LastName = ap.Last_Name__c,
                    PersonBirthdate = ap.Birthdate__c,
                    PersonMailingStreet = ap.Street__c,
                    PersonMailingCity = ap.City__c,
                    PersonMailingState = ap.State__c,
                    PersonMailingPostalCode = ap.PostalCode__c,
                    Campus_Email__pc = ap.Email_2__c,
                    HOB_Email__pc = ap.HOB_Email__c,
                    Other_Email__pc = ap.Other_Email__c,
                    Parent_Email__pc = ap.Parent_Email__c,
                    PersonHomePhone = ap.Home_Phone__c,
                    PersonMobilePhone = ap.Mobile__c,
                    PersonOtherPhone = ap.Other_Phone__c,
                    PersonEmail = ap.PersonEmail__c,
                    Phone = ap.Phone__c,
                    SAT__pc = ap.SAT__c,
                    SAT_Writing__pc = ap.SAT_Write__c,
                    SAT_Verb__pc = ap.SAT_Verb__c,
                    SAT_Math__pc = ap.SAT_Math__c,
                    HSOV_Units__pc = ap.HSOV_Units__c,
                    UGOV_Units__pc = ap.UGOV_Units__c,
                    GPA_HS__pc = ap.GPA_HS__c,
                    GPA_UG__pc = ap.GPA_UG__c,
                    ACT__pc = ap.ACT__c,
                    ACT_Read__pc = ap.ACT_Read__c,
                    ACT_Math__pc = ap.ACT_Math__c,
                    ACT_ENG__pc = ap.ACT_ENG__c,
                    Admit_Type__pc = ap.Admit_Type__c,
                    Admit_Type_Description__pc = ap.Admit_Type_Description__c,
                    Image_Now_Link__pc = ap.Image_Now_Link__c,
                    OwnerId = '005F0000001zni0',
                    RecordTypeId = '012A0000000oTZQ');
      }
      //assign the new account to the panther id
      pIdsWithAccounts.put(tempAcc.Panther_Id_Student__pc, tempAcc);
      //system.debug('************************ Account ID: ' + tempAcc.Id); 
    }
    if(ap.Opportunity_Id__c != null)
    {
      for(Opportunity o : oppList)
      {
        if(o.Id != ap.Opportunity_Id__c)continue;
        if(!(o.Stop_Updating_Stage__c && ap.StageName__c != 'Cancelled'))o.StageName = ap.StageName__c;
        o.Application_Status__c = ap.Application_Status__c;
        o.Application_Status_Code__c = ap.Application_Status_Code__c;
        o.Application_Status_Detail__c = ap.Application_Status_Detail__c;
        o.Application_Status_Detail_Code__c = ap.Application_Status_Detail_Code__c;
        o.Admit_Term__c = ap.Admit_Term__c;
        o.Admit_Term_Code__c = ap.Admit_Term_Code__c;
        o.Residency__c = ap.Residency__c;
        o.Residency_Code__c = ap.Residency_Code__c;
        o.Academic_Plan__c = ap.Academic_Plan__c;
        o.Application_Id__c = ap.Application_Id__c;
        o.Sub_Plan__c = ap.Sub_Plan__c;
        o.PS_Removed__c = ap.PS_Removed__c;
        o.Generated_From__c = ap.Generated_From__c;
        o.Application_Fee_Status__c = ap.Application_Fee_Status__c;
        o.Application_Fee_Paid__c = ap.Application_Fee_Paid__c;
        o.Application_Fee_Date__c = ap.Application_Fee_Date__c;
        o.Plan_Changed__c  = ap.Plan_Changed__c;
        o.Plan_Changed_Date__c = ap.Plan_Changed_Date__c;
        o.Enrolled_Orientation_Course__c = ap.Enrolled_Orientation_Course__c;
        o.Enrolled_Credit_Course__c = ap.Enrolled_Credit_Course__c;
      }
    }
    else if(ap.Opportunity_Id__c == null && ap.Lead_Id__c == null)
    {
      tempOpp = new Opportunity(  StageName = ap.StageName__c,
                    Application_Status__c = ap.Application_Status__c,
                    Application_Status_Code__c = ap.Application_Status_Code__c,
                    Application_Status_Detail__c = ap.Application_Status_Detail__c,
                    Application_Status_Detail_Code__c = ap.Application_Status_Detail_Code__c,
                    Admit_Term__c = ap.Admit_Term__c,
                    Admit_Term_Code__c = ap.Admit_Term_Code__c,
                    First_Admit_Term__c = ap.Admit_Term__c,
                    First_Admit_Term_Code__c = ap.Admit_Term_Code__c,
                    Residency__c = ap.Residency__c,
                    Residency_Code__c = ap.Residency_Code__c,
                    Academic_Plan__c = ap.Academic_Plan__c,
                    Application_Id__c = ap.Application_Id__c,
                    Name = ap.First_Name__c + ' ' + ap.Last_Name__c + '-' + ap.Academic_Plan__c,
                    AccountId = ap.Account_Id__c,
                    Sub_Plan__c = ap.Sub_Plan__c,
                    PS_Removed__c = ap.PS_Removed__c,
                    Generated_From__c = ap.Generated_From__c,
                    Application_Fee_Status__c = ap.Application_Fee_Status__c,
                    Application_Fee_Paid__c = ap.Application_Fee_Paid__c,
                    Application_Fee_Date__c = ap.Application_Fee_Date__c,
                    Plan_Changed__c  = ap.Plan_Changed__c,
                    Plan_Changed_Date__c = ap.Plan_Changed_Date__c,
                    Enrolled_Orientation_Course__c = ap.Enrolled_Orientation_Course__c,
                    Enrolled_Credit_Course__c = ap.Enrolled_Credit_Course__c,
                    OwnerId = '005F0000001zni0',
                    RecordTypeId = '012A0000000SDYt',
                    UpdatedByBoomi__c = true,
                    Created_By_Boomi__c = true,
                    CloseDate = System.today());
      oppToInsert.add(tempOpp);
    }
  }
  accToInsert = pIdsWithAccounts.values();
  update accList;
    
  insert accToInsert;
    
  update oppList;
    
  for(Account a : accToInsert)
  {
    for(Applicant__c ap : trigger.new)
    {
      if(a.Panther_Id_Student__pc != ap.Panther_Id__c)continue;
      for(Opportunity o : oppToInsert)
      {
        if(o.Application_Id__c != ap.Application_Id__c)continue;
        o.AccountId = a.Id;
        //system.debug('************** acc record type: ' + a.RecordTypeId + ' opp record type: ' + o.RecordTypeId);
      }
    }
  }
  insert oppToInsert;
    
  Database.LeadConvert[] leadsToConvert = new Database.LeadConvert[leadList.size()];
    Database.Leadconvert converter;
    LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true and MasterLabel = 'Highly Engaged' limit 1];
           
    system.debug('************************************************************************** convertStatus: ' + convertStatus);
           
    Database.LeadConvertResult[] lcr;
    Integer counter = 0;
    accToInsert = new List<Account>();
    
    List<Lead> leadUpdate = new List<Lead>();
    Boolean add = false;
    
    for(Lead l : leadList)
    {
      String lOwner;
      lOwner = l.OwnerId;
      if(lOwner.startsWith('00G'))
      {
        l.OwnerId = '005F0000001zni0'; //liliana blanco
               
        if(l.Description == null)l.Description = '***automated process***';
        else l.Description = l.Description + ' / ***automated process***';
               
        add = true;  
      }
      
      if(l.Status <> 'Highly Engaged') //Update the status so the SF workflow can release the lead from the email automation strategy and the lead can be convertered
      {
        l.Status = 'Highly Engaged';
        l.Lead_Phase__c = 'Qualified';
      add = true;  
      }
      
      
      if(add) leadUpdate.add(l);
      
      for(Applicant__c ap : trigger.new)
      {
        if ((l.Email != null && (l.Email == ap.Email_2__c || l.Email == ap.HOB_Email__c || l.Email == ap.Other_Email__c || l.Email == ap.Parent_Email__c || l.Email == ap.PersonEmail__c)) || 
            (l.Email_2__c != null &&(l.Email_2__c == ap.Email_2__c || l.Email_2__c == ap.HOB_Email__c || l.Email_2__c == ap.Other_Email__c || l.Email_2__c == ap.Parent_Email__c || l.Email_2__c == ap.PersonEmail__c)))
        {
         tempAcc = new Account(Panther_Id_Student__pc = ap.Panther_Id__c,
                   FirstName = ap.First_Name__c,
                   LastName = ap.Last_Name__c,
                   PersonBirthdate = ap.Birthdate__c,
                   PersonMailingStreet = ap.Street__c,
                   PersonMailingCity = ap.City__c,
                   PersonMailingState = ap.State__c,
                   PersonMailingPostalCode = ap.PostalCode__c,
                   Campus_Email__pc = ap.Email_2__c,
                   HOB_Email__pc = ap.HOB_Email__c,
                   Other_Email__pc = ap.Other_Email__c,
                   Parent_Email__pc = ap.Parent_Email__c,
                   PersonHomePhone = ap.Home_Phone__c,
                   PersonMobilePhone = ap.Mobile__c,
                   PersonOtherPhone = ap.Other_Phone__c,
                   PersonEmail = ap.PersonEmail__c,
                   Phone = ap.Phone__c,
                   SAT__pc = ap.SAT__c,
                   SAT_Writing__pc = ap.SAT_Write__c,
                   SAT_Verb__pc = ap.SAT_Verb__c,
                   SAT_Math__pc = ap.SAT_Math__c,
                   HSOV_Units__pc = ap.HSOV_Units__c,
                   UGOV_Units__pc = ap.UGOV_Units__c,
                   GPA_HS__pc = ap.GPA_HS__c,
                   GPA_UG__pc = ap.GPA_UG__c,
                   ACT__pc = ap.ACT__c,
                   ACT_Read__pc = ap.ACT_Read__c,
                   ACT_Math__pc = ap.ACT_Math__c,
                   ACT_ENG__pc = ap.ACT_ENG__c,
                   Admit_Type__pc = ap.Admit_Type__c,
                   Admit_Type_Description__pc = ap.Admit_Type_Description__c,  
                   Image_Now_Link__pc = ap.Image_Now_Link__c,
                   OwnerId = '005F0000001zni0',
                   RecordTypeId = '012A0000000oTZQ');        
      accToInsert.add(tempAcc);
        }
      }
    }
    update leadUpdate;
        
    insert accToInsert;
        
    Set<String> ownerIds = new Set<String>();
    String lOwner;
    
    for(Lead l : leadList)
    {
      lOwner = l.OwnerId;
      if(lOwner.startsWith('00G'))l.OwnerId = '005F0000001zni0'; //verify if the owner of the leads is a queue and assign the Enrollment Coordinator
      ownerIds.add(l.OwnerId);
    }
    List<User> owners = [select Id, IsActive from User where Id IN :ownerIds];
   
    //system.debug('****************************************************************  trigger.new: ' + trigger.new);
    
    for(Lead l : leadList)
    {
      for(User u : owners)
      {
        if(u.Id != l.OwnerId) continue;
        converter = new Database.Leadconvert();
        
        for(Account acc : accToInsert)
        {                 
          if((l.Email != null && (l.Email == acc.Campus_Email__pc || l.Email == acc.HOB_Email__pc || l.Email == acc.Other_Email__pc || l.Email == acc.Parent_Email__pc || l.Email == acc.PersonEmail)) ||
             (l.Email_2__c != null && (l.Email_2__c == acc.Campus_Email__pc || l.Email_2__c == acc.HOB_Email__pc || l.Email_2__c == acc.Other_Email__pc || l.Email_2__c == acc.Parent_Email__pc || l.Email_2__c == acc.PersonEmail)))// continue;
          {
            for(Applicant__c ap : trigger.new)
            {            
              if(ap.Panther_ID__c == acc.Panther_Id_Student__pc)
              {
                converter.setLeadId(l.Id);
                converter.setAccountId(acc.Id);
                converter.setDoNotCreateOpportunity(false);
                converter.setConvertedStatus(convertStatus.MasterLabel);
                converter.setOpportunityName(ap.Name + '-' + ap.Academic_Plan__c);
                if(u.IsActive)converter.setOwnerId(l.OwnerId);
                else converter.setOwnerId('005F0000001zni0');
                leadsToConvert [counter] = converter;
                break;
              }
            }
          }
        }
        counter++;
      }
    }
    lcr = Database.convertLead(leadsToConvert);
    oppIds = new List<String>();
    for(Database.LeadconvertResult lc : lcr)
    {
      oppIds.add(lc.getOpportunityId());
    }
  oppList = [select Id, Name, StageName, Application_Status__c, Application_Status_Code__c, Application_Status_Detail__c, Application_Status_Detail_Code__c,
        Admit_Term__c, Admit_Term_Code__c, Residency__c, Residency_Code__c, Academic_Plan__c, Application_Id__c, Sub_Plan__c,PS_Removed__c,
        Generated_From__c, Application_Fee_Status__c, Application_Fee_Paid__c, Application_Fee_Date__c, Plan_Changed__c,Plan_Changed_Date__c,
        Enrolled_Orientation_Course__c, Enrolled_Credit_Course__c
        from Opportunity
        where Id IN :oppIds];
                
  for(Opportunity o : oppList)
  {
    for(Applicant__c ap : trigger.new)
    {
      if(o.Name != ap.Name + '-' + ap.Academic_Plan__c)continue;
      o.StageName = ap.StageName__c;
      o.Application_Status__c = ap.Application_Status__c;
      o.Application_Status_Code__c = ap.Application_Status_Code__c;
      o.Application_Status_Detail__c = ap.Application_Status_Detail__c;
      o.Application_Status_Detail_Code__c = ap.Application_Status_Detail_Code__c;
      o.Admit_Term__c = ap.Admit_Term__c;
      o.Admit_Term_Code__c = ap.Admit_Term_Code__c;
      o.Residency__c = ap.Residency__c;
      o.Residency_Code__c = ap.Residency_Code__c;
      o.Academic_Plan__c = ap.Academic_Plan__c;
      o.Application_Id__c = ap.Application_Id__c;
      o.Sub_Plan__c = ap.Sub_Plan__c;
      o.PS_Removed__c = ap.PS_Removed__c;
      o.Generated_From__c = ap.Generated_From__c;
      o.Application_Fee_Status__c = ap.Application_Fee_Status__c;
      o.Application_Fee_Paid__c = ap.Application_Fee_Paid__c;
      o.Application_Fee_Date__c = ap.Application_Fee_Date__c;
      o.Plan_Changed__c  = ap.Plan_Changed__c;
      o.Plan_Changed_Date__c = ap.Plan_Changed_Date__c;
      o.Enrolled_Orientation_Course__c = ap.Enrolled_Orientation_Course__c;
      o.Enrolled_Credit_Course__c = ap.Enrolled_Credit_Course__c;
      o.OwnerId = '005F0000001zni0';
      o.RecordTypeId = '012A0000000SDYt';
      o.UpdatedByBoomi__c = true;
    }
  }
  update oppList;
}

Crystal Rochlitz 4Crystal Rochlitz 4
I wouldn't even know where to beigin debugging this hot mess. (No offense) First thing I notice is that there are no methods and no debug statements. These things alone will help IMMENSELY when trying to determine where your problem lies. I also noticed that there IDs being stored in lists as strings and queries running against these lists. That may be a problem. Speaking of IDs, hard coding in IDs (RecordIds, OwnerIds, etc.) is no bueno. IDs vary from sandbox to sandbox and then again in production. So, even if you got this working now, no guarantee that it will continue to stay working in the future. Run a query, store the result in a variable, pass the variable. Split some of these procedures into different methods with many, many debug statements to control and monitor the flow, and do the suggestions above then once you have a better idea of where the problem is update here for more help. GL :)
Crystal Rochlitz 4Crystal Rochlitz 4
Ok, just to clarify...no methods in triggers (I forget these things). You could create classes for each trigger logic, then call the classes from a handler. But, I digress...