• Allison Humphrey 7
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I was adding in an additional section & I think I messed up the ending with the Catch exception.  It was working fine before I added in the section for Creative BQA & not it's not firing for any of the items. I think I erased some part of the catch exception & didn't get it correct.  I was able to get it to where it would save, but it doesn't seem to be firing to make the changes requested.  
ANY help would be greatly appreciated.
Thanks!
Here is my code: 

trigger TaskTrigger on Task (before insert) {

    try{
    boolean active = [Select Active__c from TriggerOptions__c where Name = 'DisplayTaskTrigger' limit 1].Active__c;
    
    
   
    if(active==true){
        for(Task t:Trigger.New){
            try{
                // if Subject = "AO - Advertiser Tagging & QA" then recordtype is "Ad Tag & QA"
                ID adTagQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Ad Tag & QA').getRecordTypeId();
                if(t.Subject=='AO - Advertiser Tagging & QA'){
                    t.RecordTypeId=adTagQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                         update t;
                    }
                   
                }
                
                // if Subject = "AO - Technical QA  " then recordtype is "Technical QA"
                ID technicalQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Technical QA').getRecordTypeId();
                if(t.Subject=='AO - Technical QA'){
                    t.RecordTypeId=technicalQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                         update t;
                    }
                   
                }
                
                // if Subject = "AO - Setup Network Pixels" then recordtype is "Pixel Setup"
                ID pixelSetupTypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Pixel Setup').getRecordTypeId();
                if(t.Subject=='AO - Setup Network Pixels'){
                    t.RecordTypeId=pixelSetupTypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                        update t;
                    }
                } 
                 // if Subject = "AM - Creative BQA" then recordtype is "Creative BQA"
                ID creativeBQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Creative BQA').getRecordTypeId();
                if(t.Subject=='AM - Creative BQA'){
                    t.RecordTypeId=creativeBQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                        update t;
                   }                    
                }
 } catch(Exception e){
        system.debug(e);}  
    
    
    }
    }
    
} catch(Exception e){
        system.debug(e);}
}
I was adding in an additional section & I think I messed up the ending with the Catch exception.  It was working fine before I added in the section for Creative BQA & not it's not firing for any of the items. I think I erased some part of the catch exception & didn't get it correct.  I was able to get it to where it would save, but it doesn't seem to be firing to make the changes requested.  
ANY help would be greatly appreciated.
Thanks!
Here is my code: 

trigger TaskTrigger on Task (before insert) {

    try{
    boolean active = [Select Active__c from TriggerOptions__c where Name = 'DisplayTaskTrigger' limit 1].Active__c;
    
    
   
    if(active==true){
        for(Task t:Trigger.New){
            try{
                // if Subject = "AO - Advertiser Tagging & QA" then recordtype is "Ad Tag & QA"
                ID adTagQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Ad Tag & QA').getRecordTypeId();
                if(t.Subject=='AO - Advertiser Tagging & QA'){
                    t.RecordTypeId=adTagQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                         update t;
                    }
                   
                }
                
                // if Subject = "AO - Technical QA  " then recordtype is "Technical QA"
                ID technicalQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Technical QA').getRecordTypeId();
                if(t.Subject=='AO - Technical QA'){
                    t.RecordTypeId=technicalQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                         update t;
                    }
                   
                }
                
                // if Subject = "AO - Setup Network Pixels" then recordtype is "Pixel Setup"
                ID pixelSetupTypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Pixel Setup').getRecordTypeId();
                if(t.Subject=='AO - Setup Network Pixels'){
                    t.RecordTypeId=pixelSetupTypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                        update t;
                    }
                } 
                 // if Subject = "AM - Creative BQA" then recordtype is "Creative BQA"
                ID creativeBQATypeID = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Creative BQA').getRecordTypeId();
                if(t.Subject=='AM - Creative BQA'){
                    t.RecordTypeId=creativeBQATypeID;
                    if(Schema.SObjectType.Task.isUpdateable()){
                        update t;
                   }                    
                }
 } catch(Exception e){
        system.debug(e);}  
    
    
    }
    }
    
} catch(Exception e){
        system.debug(e);}
}