How to Run Tasks in Sequence

This method is no longer relevant. If possible, use How to Schedule Jobs with Dependencies


The following function is useful when you need to run several tasks (Data Loads, Calculated Field Sets, Calculation Flows,...) in a sequence and ensure that they wait for each other.

Control Table

SequenceNameOrderTypeTaskNameStateLastRun
DM X load1DLSalesDFtoDS<no value> / RUNNING / DONE / ERROR
DM X load2DLSalesDStoDM

DM X load3DLSalesDMCalculation

  • SequenceName – You can have more sequences. All tasks which should run in one sequence must have the same SequenceName.
  • Order – Sets the order in which the tasks should be executed. When two or more tasks in the sequence have the same OrderOfTask number, they will run in parallel.
  • Type – Determines what should be executed.
  • TaskName – Defines the name of the DL, CFS etc.
  • State – Informs about the task.
    • <no value> – Execution pending.
    • RUNNING – Execution in progress.
    • DONE – Execution finished successfully.
    •  ERROR – Execution finished with an error (if a task ends with an error, the sequence stops).
  • LastRun – Shows when the last run of the task ended.

Scheduler

Scheduler is a simple Calculation Flow Formula which is executed every minute and starts the tasks according to the Control Table. 

Installation

  1. In Groovy Library, add a new element called "Sequencer" with the following code: Sequencer Library Code.groovy
  2. Create a new Calculation Flow Formula, scheduled for every minute, with one element with this code: 

    lib.Sequencer.processAllSequences(actionBuilder)
  3. Import the Price Parameter called "SequenceControlTable". The import ZIP file is attached: PP_SequenceControlTable_for_Import.zip

Running Your Own Sequence

From your code (usually from a CFF but generally from any code which is allowed to modify Price Parameters) call the following:

lib.Sequencer.startSequence("<your sequence name>")