Question

I have a simple trigger to copy the StartDateTime from a calendar event into a field called "Service Start Date" on the related Opportunity any time a calendar event is created or changed.

I'm stuck on converted the StartDateTime to a regular Date field, which is on the opportunity.

trigger EventServiceStartDateforOpp on Event (after insert, after update) {
List<Opportunity> opps = new List<Opportunity>{};

if (trigger.isInsert)
{
for (Event t : trigger.new)
{
if (t.OwnerId == '02340000000WATv')
{opps.add(new Opportunity(Id=t.WhatId, Service_Start_Date__c=t.StartDateTime));
}}}}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top