+ Start a Discussion

time-delayed trigger




We have a request to write a trigger to send out an email message at a specific time delay after a situation happened. Because of the complex logic this can't be done via workflow. Anyway to mimic those behavior in my own apex trigger code?


Thanks so much.


You can use the schedulable interface to schedule Apex code similar to a cron job, for one time use or repeating use from within your trigger code.


See this page for details:





Gabriel Alack
Contact Us - We Can Help!
Salesforce Superheroes
1-888-407-9578 x122




Just write trigger as you need to implement complex logic.

At the same time use the Benefits of work flow to send email after some time, by updating some field in trigger and that cause the match of WF Entry criteria.

Use Time Depended actions for this which are available with WF.


But in this case mind that trigger can fire for bulk records update also and write code and Entry criteria accordingly.




Thanks for the suggestions. I'll try.