• 1Installation
  • 2Preliminary Knowledge
  • 3Hello World Job
  • 4Cron Expression Jobs
  • 5Repeating Jobs
  • 6Job Management

Job.apex

  • Docs
  • Tutorials
Getting started with Job.apex

Hello World Job

Below is how we create a simple HelloWorldJob.

public class HelloWorldJob extends Func {
    public HelloWorldJob() {
        super(1);
    }

    public override Object exec(Object context) {
        System.debug('Hello World');
        return null;
    }
}

We can directly use any Func as a Job executor.

Here is how we create a job.

Job j = new Job('helloworld', new HelloWorldJob());

And then we set when the job will execute.

j.everyDay().atHour(8);

Finally we schedule the job.

j.schedule();

We can combine all of these into:

new Job('helloworld', new HelloWorldJob())
    .everyDay()
    .atHour(8)
    .schedule();
Done