• Tyler Makula
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
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){