Skip to main content

Triggers

The concept of triggers is introduced to have fine-grained control over the transitions in the workflow state-machine. Each transition can have a number of triggers, depending on the needs of your applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution..

This page lists the available triggers and their options. For guidance on which trigger fits which situation, see modeling behavior in the general overview.

CRUD Triggers​

process automation Two crud-action triggers are supported currently; OnCreate and OnModify. The OnCreate will only trigger once for a dataElement when it is created through its logic Bean. The OnModify on the other hand will trigger every time an element is modified through the logic Bean. The event information will contain the Details projectionProjectionA tailored subset of fields on a DataElement designed to encapsulate data for a specific technical or functional view. as presented in the logic layerLayerLogical separation of functionality within a single system/application, focused on code organization..

Transition Trigger​

process automation The OnTransition triggers for every element which is transitioned by the process automation component. It is primarily useful for a sequence of tasks which are executed autonomously.

DataCommand Trigger​

process automation It is common for applicationsApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution. to transition based on a user action or other external source. The ByDataCommand trigger makes it easy to trigger (a set of) transitions through a command. Define a command on the target element with hasTargetInstance=true. This command can now be used as the target of the trigger, and will expand the required implementation. Two options are defined on the DataCommand to customize behavior.

Option
workflow.trigger.button DataCommand

Adds a button to the (knockout) UI to perform this command. The button will only be visible in valid begin-states.

<options>
<workflow.trigger.button/>
</options>
Option
workflow.trigger.blockingMs DataCommand

When defined, the command will perform linked transitions in a blocking manner. The until_complete option value indicates no timeout, while a positive integer indicates a timeout (in ms) for the transition to complete.

<options>
<workflow.trigger.blockingMs>until_complete</workflow.trigger.blockingMs>
</options>
<options>
<workflow.trigger.blockingMs>500</workflow.trigger.blockingMs>
</options>

DataOperation Trigger​

process automation Similar to the ByDataCommand trigger, we can also get the same functionality through data-operations. Create a Workflow.Trigger data-operation with a single TargetParameter.

Then create a ByDataOperation trigger on the transition to assign said transition to the data-operation. This trigger also implements the same blocking logic as the DataCommand trigger.

Option
workflow.trigger.blockingMs DataOperation

When defined, the operation will perform linked transitions in a blocking manner. The until_complete option value indicates no timeout, while a positive integer indicates a timeout (in ms) for the transition to complete.

<options>
<workflow.trigger.blockingMs>until_complete</workflow.trigger.blockingMs>
</options>
<options>
<workflow.trigger.blockingMs>500</workflow.trigger.blockingMs>
</options>

Schedule Trigger​

process automation The Schedule trigger allows for defining a schedule using a cron-like syntax for each transition. The main difference with cron is that we also support a 'seconds' and 'year' property.

The following trigger configurations show some examples of what is possible with a schedule.

<trigger type="workflows::Schedule">
<name>Every10Seconds</name>
<second>*/10</second>
<minute>*</minute>
<hour>*</hour>
</trigger>

Each fieldFieldA property of a DataElement expanded to a database column and user interface input element. accepts the same values as its cron counterpart. FieldsFieldA property of a DataElement expanded to a database column and user interface input element. that are left out take the default below, so an empty schedule results in "Every day at 00:00 local time".

fieldFieldA property of a DataElement expanded to a database column and user interface input element.defaultexample
second0*/30 "every 30 seconds"
minute0*/5 "every 5 minutes"
hour01,13 "twice a day at 1 o'clock"
dayOfWeek*Tue,Fri "every Tuesday and Friday"
dayOfMonth*1 "first of every month"
month*1,2 "only in January and February"
year*2025 "only in 2025"
timezoneJVM timezoneEurope/Amsterdam

The schedule trigger will use the Eq or Se finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. on the target fieldFieldA property of a DataElement expanded to a database column and user interface input element. by default. To override this the schedule.finder.name option can be added to the transition.

Option
schedule.finder.name Transition

Specify which finderFinderA search specification combining field-operator pairs to execute standard data queries on a DataElement. should be used to retrieve instances when schedules trigger.

<options>
<schedule.finder.name>findByMyCondition</schedule.finder.name>
</options>
Option
schedule.expression.dynamic Schedule

Allows you to adjust the schedule at runtime before it is executed. This allows you to use a config file or database configuration to change when a schedule is triggered.

When enabled, the generated «Transition»Schedule class builds the schedule through a getExpression method, which receives the name of the schedule trigger. Its custom-dynamic-expressions anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. lets you fill in the expression at runtime, for example from a config file.

<options>
<schedule.expression.dynamic/>
</options>

Options impacting batching also apply.

FieldTimer Trigger​

process-automation-component1.13.0+

process automation Some tasks must happen at a certain date or timestamp. By adding the FieldTimer trigger for a certain Timestamp fieldFieldA property of a DataElement expanded to a database column and user interface input element., the systemSystemA set of interconnected components that work together to achieve a specific purpose or function. will schedule the task to be executed at the timestamp stored in that fieldFieldA property of a DataElement expanded to a database column and user interface input element..

The trigger follows certain rules to keep the trigger up-to-date:

  • A TimerJob is always scheduled after a transition to the beginState is performed.
  • A TimerJob is scheduled on create when the beginState is an initialState.
  • A TimerJob is scheduled on modify when the beginState is equal to the current state.
  • When a TimerJob is scheduled for this workflow on the same element, previous timers are cancelled.

A timestamp that is already in the past when the TimerJob is scheduled triggers the transition immediately.

Option
trigger.timer.offset FieldTimer

Apply an offset to the FieldTimer trigger. Can be positive (later) or negative (earlier) in hours, minutes, seconds. E.g. +5m runs five minutes later. -1h runs an hour early.

<options>
<trigger.timer.offset>+5m</trigger.timer.offset>
</options>
<options>
<trigger.timer.offset>-1h</trigger.timer.offset>
</options>

Custom Trigger​

The available triggers do not provide a model for any imaginable use case. The custom trigger provides a low bar for extending the systemSystemA set of interconnected components that work together to achieve a specific purpose or function. with your own triggers. It can also be used to simply document the way custom code interacts with the workflow/transition.

When creating expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. for your own type of trigger the custom trigger can be used as a prototype without the need for your own metamodel. You can add a marker option to the custom trigger to indicate your expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. should work here.

When the model for your expanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. requires more information than is provided by the custom trigger it is recommended to switch to a metamodel extending the Trigger abstract type.

FlowEngine Trigger​

Adding the FlowEngine trigger indicates the transition should be picked up by a FlowEngineBean. A FlowEngine fetches elements in a given status at a regular predefined interval. The resulting elements are then scheduled on the queue as a batch.

Legacy

The FlowEngine trigger corresponds to a StateTask element in the workflow base-component. More information.

Options​

Configuring the FlowEngine will use the job options and batch options. The legacy options on FlowElement are documented below.

Legacy Options
Option
flowEngine.workflow.responsible FlowElementComponentApplicationCascading

Configures the responsible fieldFieldA property of a DataElement expanded to a database column and user interface input element. on Workflow.

<options>
<flowEngine.workflow.responsible>workflow</flowEngine.workflow.responsible>
</options>
Option
flowEngine.engineService.sequencingStrategy FlowElement

Configures the sequencingStrategy fieldFieldA property of a DataElement expanded to a database column and user interface input element. on EngineService.

<options>
<flowEngine.engineService.sequencingStrategy>greedy</flowEngine.engineService.sequencingStrategy>
</options>
Option
flowEngine.engineService.waitTime WorkflowFlowElementComponentApplicationCascading

Configures the waitTime fieldFieldA property of a DataElement expanded to a database column and user interface input element. on EngineService.

<options>
<flowEngine.engineService.waitTime>5</flowEngine.engineService.waitTime>
</options>
Option
flowEngine.engineService.timeWindowGroup FlowElement

Configures the timeWindowGroup fieldFieldA property of a DataElement expanded to a database column and user interface input element. on EngineService.

<options>
<flowEngine.engineService.timeWindowGroup>daytime</flowEngine.engineService.timeWindowGroup>
</options>
Option
flowEngine.engineService.batchSize WorkflowFlowElement

Configures the batchSize fieldFieldA property of a DataElement expanded to a database column and user interface input element. on on EngineService.

<options>
<flowEngine.engineService.batchSize>100</flowEngine.engineService.batchSize>
</options>
Option
flowEngine.engineService.batchTimeout WorkflowFlowElement

Configures the BATCH_TIMEOUT fieldFieldA property of a DataElement expanded to a database column and user interface input element. on on EngineService. After the specified timeout (in seconds) the currently active batch will be cancelled if it is still busy. Defaults to 300s.

<options>
<flowEngine.engineService.batchTimeout>100</flowEngine.engineService.batchTimeout>
</options>
Option
flowEngine.engineService.maximumNumberOfNodes FlowElement

Configures the maximumNumberOfNodes fieldFieldA property of a DataElement expanded to a database column and user interface input element. on EngineService.

<options>
<flowEngine.engineService.maximumNumberOfNodes>1</flowEngine.engineService.maximumNumberOfNodes>
</options>
Option
flowEngine.stateTask.implementation FlowEngine

Configures the implementation fieldFieldA property of a DataElement expanded to a database column and user interface input element. on StateTask.

<options>
<flowEngine.stateTask.implementation>net.democritus.TaskImpl</flowEngine.stateTask.implementation>
</options>
Option
flowEngine.stateTask.maxConcurrentTasks FlowEngine

Configures the maxConcurrentTasks fieldFieldA property of a DataElement expanded to a database column and user interface input element. on StateTask.

<options>
<flowEngine.stateTask.maxConcurrentTasks>16</flowEngine.stateTask.maxConcurrentTasks>
</options>
Option
flowEngine.stateTask.params FlowEngine

Configures the params fieldFieldA property of a DataElement expanded to a database column and user interface input element. on StateTask.

<options>
<flowEngine.stateTask.params/>
</options>
Option
flowEngine.stateTask.timeout FlowEngine

Configures the timeout fieldFieldA property of a DataElement expanded to a database column and user interface input element. on StateTask.

<options>
<flowEngine.stateTask.timeout>600</flowEngine.stateTask.timeout>
</options>
Option
flowEngine.stateTask.endState FlowEngine

Overrides the endState fieldFieldA property of a DataElement expanded to a database column and user interface input element. on StateTask in case of branching tasks. Can be used to optimize a greedy strategy.

<options>
<flowEngine.stateTask.endState>EndState</flowEngine.stateTask.endState>
</options>