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
Giancarlo AmatiGiancarlo Amati 

Time based action in Apex

Dear All,
I have the following project to develop: when a Case is submitted to us, we have to first-respond it within a certain time (our SLA due date/time). I would like to implement an Apex (trigger or Class?) that fires a notification (an outbound message, or email alert ...) 5 minutes before the SLA due date/time. For example:
a case is created on 05/01/2018 at 8.00AM with priority P1. It must be first responded within 15 minutes that means, at 8.15AM (this is our SLA due date/time). I want to be able to send a notification 5 minutes before we hit the SLA due time. 
The notification (either an outbound message or an email alert) should be sent at 8.10AM, 5 mins before the SLA due date/time: 8.15AM.

I know there are Workflows and time-based action, but would it be more accurate doing in an APEX class? if so? how? 
How can I also repeat the notification many times?

Thank you.
GC

Giancarlo AmatiGiancarlo Amati
hi team, any ideas?
GC
Fazurulla GagangapalliFazurulla Gagangapalli
Hi GC-

In this scenario sync apex code or asynch batch apex is not suitable. I would recomond to go for time based workflow only.

Steps :
  • Create on custom date time field and store created date in the same field using formula field or workflow.
  • Write time based workflow based on the custome created date time field.
  • Refer the below link for firing 5 or 10 or 15 minutes etc 
  • https://sftipshack.wordpress.com/2013/10/21/the-5-minute-time-based-workflow-or-15-minute-or-30-minute/