Skip to main content
I want a custom Date field on Opportunity to be updated with the date of the related Calendar Event (owned by a specific Calendar every time) any time the event is created or updated. My trigger isn't throwing any errors, but I can't get any action to happen. 

 

What could I be forgetting?

 

trigger EventServiceStartDateforOpp on Event (after insert, after update) {

List<Opportunity> opps = new List<Opportunity>{};

if (trigger.isInsert)

{

for (Event t : trigger.new)

{

datetime tiempo = t.StartDateTime;

date d = Date.newInstance(tiempo.year(),tiempo.month(),tiempo.day());

if (t.OwnerId == '02340000000WATv')

{opps.add(new Opportunity(Id=t.WhatId, Service_Start_Date__c=d));

}}}}

3 answers
  1. Apr 24, 2014, 5:12 PM
    That is because of "if (trigger.isInsert)"  statement.

     

    Remove that if  - or extend it by if (trigger.isInsert || trigger.isupdate).
0/9000