1

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;

Thanks.

1

I'd say it all comes down to what the business user wants. Do they want that Event deleted? Or just to have an end date of the day the Lead status changed? You are correct--there is no status field on the event and what you did above moves it to the history. But the question for the business user is: is this accurate to them? They might prefer to have a specific date and have a specific message or flag on the event to indicate what happened, and that the event didn't truly take place even thought it may have been previously planned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.