• Monet Zamaripa 3
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
trigger updateOpportunty on Event (after update) {
    
    List<Id> OpportuntyIds=new List<Id>();
    List<Opportunity> OpportunitysToUpdate =new List<Opportunity>();
    for(Event e:trigger.new){
            if(String.valueOf(e.whatId).startsWith('006') == TRUE)
            if((e.subject).contains('First Meeting'))
                        {//check if the task is associated with a Opportunty
                OpportuntyIds.add(e.whatId);
            }
    }
    Map<Id,Opportunity> OpportunityMap = new Map<Id,Opportunity>([SELECT Id,Meeting_Initially_Scheduled_Date__c FROM Opportunity WHERE Id IN :OpportuntyIds]);
    
    For (Event e:trigger.new){
        Opportunity opp = OpportunityMap.get(e.whatId);
        opp.Meeting_Initially_Scheduled_Date__c = e.Initially_Scheduled__c;
        OpportunitysToUpdate.add(opp);
    }
    
    try{
        update OpportunitysToUpdate;
    }catch(DMLException e){
        system.debug('Opportunitys were not all properly updated.  Error: '+e);
    }
}
trigger updateOpportunty on Event (after update) {
    
    List<Id> OpportuntyIds=new List<Id>();
    List<Opportunity> OpportunitysToUpdate =new List<Opportunity>();
    for(Event e:trigger.new){
            if(String.valueOf(e.whatId).startsWith('006') == TRUE)
            if((e.subject).contains('First Meeting'))
                        {//check if the task is associated with a Opportunty
                OpportuntyIds.add(e.whatId);
            }
    }
    Map<Id,Opportunity> OpportunityMap = new Map<Id,Opportunity>([SELECT Id,Meeting_Initially_Scheduled_Date__c FROM Opportunity WHERE Id IN :OpportuntyIds]);
    
    For (Event e:trigger.new){
        Opportunity opp = OpportunityMap.get(e.whatId);
        opp.Meeting_Initially_Scheduled_Date__c = e.Initially_Scheduled__c;
        OpportunitysToUpdate.add(opp);
    }
    
    try{
        update OpportunitysToUpdate;
    }catch(DMLException e){
        system.debug('Opportunitys were not all properly updated.  Error: '+e);
    }
}