function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul SharmaRahul Sharma 

Event Trigger is not fired when it passes the Activity Date?

Hello Board,

 

Task has Status field, by marking it as Completed the Task is closed(Manually by a user). But for Event there is no such field, It closes automatically as the Event's end date surpases.

 

I have created a Trigger on Event which should work as soon as Activity closes. I had add a check to see if the date is less that the Event.EndDateTime.

I want the trigger to fire as soon as the Event is closed. Is there any option for doing the same?

 

Thanks for your time and help.

Best Answer chosen by Rahul Sharma
sfdcfoxsfdcfox
No, triggers only fire when a record is modified. The "closed" status for events is more of a formula field (calculated in real-time); no record is modified when the event passes from open to closed. Instead, you'd have to write a batch/scheduled class that queries all events that had a date set to the previous day, and process those records in batch.

All Answers

sfdcfoxsfdcfox
No, triggers only fire when a record is modified. The "closed" status for events is more of a formula field (calculated in real-time); no record is modified when the event passes from open to closed. Instead, you'd have to write a batch/scheduled class that queries all events that had a date set to the previous day, and process those records in batch.
This was selected as the best answer
Rahul SharmaRahul Sharma
sfdcfox, Thanks for your reply.
I was trying to avoid the batch class as event can close at any minute where as; The minimum time batch can scheduled is about 1 hour. So if the Event closes after execution of batch, then it will be processed in next batch.

It would have been great if there could the standard way of doing it.
Thanks!!
Chirag MehtaChirag Mehta
Tried doing it via Change Data Capture on Event Object and EventChangeEvent trigger, however, it fires only when any Event data is changed but it doesn't fire when it passes Activity Date Time. Had it worked (or am I missing something), then it would have been an optimum solution.