/** * Schedulable Apex class for {describe the scheduled operation}. * Delegates heavy processing to a Batch or Queueable job. * Keep execute() lightweight — it should only launch other jobs. * @author Generated by Apex Class Writer Skill * * @example * // Schedule to run daily at 2 AM * String jobId = System.schedule( * '{ClassName} - Daily', * {ClassName}.CRON_DAILY_2AM, * new {ClassName}() * ); * * // Or use the convenience method * String jobId = {ClassName}.scheduleDaily(); */ public with sharing class {ClassName} implements Schedulable { // ─── CRON Expressions ──────────────────────────────────────────────── // Seconds Minutes Hours Day_of_month Month Day_of_week Optional_year /** Runs daily at 2:00 AM */ public static final String CRON_DAILY_2AM = '0 0 2 * * ?'; /** Runs every weekday at 6:00 AM */ public static final String CRON_WEEKDAYS_6AM = '0 0 6 ? * MON-FRI'; /** Runs hourly at the top of the hour */ public static final String CRON_HOURLY = '0 0 * * * ?'; // ─── Schedulable Interface ─────────────────────────────────────────── /** * Entry point for the scheduled execution. * Delegates to a Batch or Queueable for the actual work. * @param sc The schedulable context */ public void execute(SchedulableContext sc) { // Option A: Launch a Batch job // Database.executeBatch(new {BatchClassName}(), 200); // Option B: Launch a Queueable job // System.enqueueJob(new {QueueableClassName}(params)); // TODO: Implement delegation to appropriate async job } // ─── Convenience Scheduling Methods ────────────────────────────────── /** * Schedules this job to run daily at 2 AM * @return The scheduled job Id */ public static String scheduleDaily() { return System.schedule( '{ClassName} - Daily 2AM', CRON_DAILY_2AM, new {ClassName}() ); } /** * Aborts this scheduled job by name * @param jobName The name used when scheduling */ public static void abort(String jobName) { for (CronTrigger ct : [ SELECT Id FROM CronTrigger WHERE CronJobDetail.Name = :jobName ]) { System.abortJob(ct.Id); } } }