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
AngelikaAngelika 

APEX Scheduler Class or custom apex recurring time trigger for recurring email reminders?

 
 Hi,
 
The salesdepartment in my organization needs to review contracts 14 days before they are due recurring every year. We need to find a way that reminds them to review the information 14 days before the review date EVERY YEAR (recurring).
 
Time based work flows will not work because they will only occur once. I am considering using a custom APEX trigger to create a new evaluation task every time the previous one is completed or using a scheduled apex class. According to message board post, the class would run every day, find the records that meet the criteria, build the emails off of those records and email the correct recipients in the sales team.
 
 
 
Jerun JoseJerun Jose
Being fond of coding, I would go with the scheduled apex. Its quite easy to build considering you have a fairly simple requirement.
AngelikaAngelika

Do you have any advice on how to do this (make a scheduled APEX class? I have never built anything in APEX, only done basic tutorials.

 

Thanks!

Jerun JoseJerun Jose

Depending on the volume of records that you are expecting to be emailed each day, you can either do a simple scheduled job or a scheduled job that kicks off a batch apex.

You can create a simple scheduled job by using the info at:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

You will need to add logic to identify the records that need to be updated (build a query with a proper where clause), to send the emails(either through Messaging.sendEmail or through field updates which trigger a workflow email alert)

 

A batch apex will have to do all the above as well, just that it will have to be done a little bit different.