I got a requirement to close all the open events and tasks of a Lead when it reaches a specific status. I did some analysis and figured out that it is possible only with a trigger.
As to closing the Tasks, I queried Task object using "WhoId" field and set the Status to Completed which closed all the tasks of a Lead.
However for the events, I am not seeing a status field in the Event object. I was wondering how can we close the open events for a lead. Is it by setting the eventdate=currentdate Or any other mechanism?
Would appreciate your help.
UPDATE I just executed the below code on an event and it moved the event to "Activity History" but not sure this is the right approach.
Event event=[select StartDateTime,EndDateTime from Event where id='00Uo0000001zGPbEAM']; event.StartDateTime = Date.today().addDays(-1); event.EndDateTime=Date.today().addDays(-1); update event;