Is it possible to sequence Cron Jobs?


We have multiple Cron Jobs that we would like to run in succession (CronJob1 runs and finishes before CronJob2, CronJob2 runs and finishes before CronJob3, etc.). Is it possible to enforce such a sequence or can we only schedule them to execute at different times (CronJob1 runs @ 4:00 AM, CronJob2 runs @ 5:00 AM, etc.)?


this sounds like you want to look at the type Workflow and WorkflowStep?


A CronJob just executes an action. Instead of having 3 CronJobs configured to call action1, action2, and action3, respectively, you could reduce them to a single CronJob that executes an action whose implementation does:

function executeActions() {

That will execute the 3 actions in sequence.


@ryan.louie connect with @erick.alanis who looked into Workflow for another customer.


For more details about Workflow in the static/console check:
Help -> Documentation -> Topics -> Workflow.

Then check the Workflow Types, I think you should check WorkflowActionStep or WorkflowBatchStep.

If you use Batch, you need to define your steps as below. For more details check WorkflowBatchStep.makeWorkflowBatchStep

var step1 = WorkflowBatchStep.makeWorkflowBatchStep(‘testWorkflow10’, ‘testBatchWorkflow10_step1’, SomeBatchJob, null, null, ‘testBatchWorkflow10_step2’);

var step2 = WorkflowBatchStep.makeWorkflowBatchStep(‘testWorkflow10’, ‘testBatchWorkflow10_step2’, AnotherBatchJob, null, null, null);

var steps = [step1, step2];

//function for creating a sequence workflow
var wf = Workflow.createSequenceWorkflow( ‘testWorkflow10’, ‘testBatchWorkflow10’, steps);

//start workflow

//check status

1 Like