Accessing Task Resources During Execution
Accessing Task Resources During Execution
Access to the Task resources in Service / Message Delegates is provided by the Variables
class. It comes with methods which return certain kinds of Task resources. The most commonly used ones are the start Task, referring to the Task / Message Start Event responsible for starting the process, and the latest Task, referring to most recently received Task / Message.
In principle, this is sufficient to access all information in a Task resource, since there is access to the full in-memory representation of the Task resource. This however can be very cumbersome to use and produces a lot of boilerplate when traversing the resource tree to access certain common elements.
Instead of navigating the Task resource's element tree, it is recommended to use the ProcessPluginApi's TaskHelper
in conjunction with the method above. The TaskHelper
class offers specific methods related to Task resources.
The most common use case for this is retrieving data from a Task's Input Parameter or creating a new Input Parameter for a Message Delegate's getAdditionalInputParameters
method. When retrieving data from a Task's Input Parameter one first has to get to the Input Parameter one is looking to extract data from. The TaskHelper's
getters for Input Parameters are useful to find the right one. The methods will try to match the provided CodeSystem and Code to any Input Parameter of the provided Task resource. Depending on the method it is possible to receive all matches or just the first one.
To create new Input Parameters to attach to a Task resource, one may invoke the TaskHelper#createInput
method. This is most often used when overriding the getAdditionalInputParameters
method of a Message Delegate.
Related Topics
Accessing BPMN Process Variables, Message Delegates, Service Delegates, Task