• Tyler Makula
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I am trying to write an Apex Trigger that will automatically assign a value of 'Meeting' to the custom picklist field Activity_Type__c on the Event object. Because this is a required field, the only way it can be Null is if the Event was created through Lightning Sync from Outlook to Salesforce. I am getting a code coverage error for this. Does anyone have any ideas on improving this code?

trigger Update_Event_Activity_Type on Event (before insert) {

     try {  
    
    //iterate over the new activities
    for(Event newEvent : trigger.new){
        if(newEvent.Activity_Type__c == Null){
            newEvent.Activity_Type__c = 'Meeting';
        }  
     }            
    }
    
    Catch(Exception e){
      system.debug(e);
    }
}