This feature is available since midPoint 3.7. Some of its parts (namely, defining variables using expressions other than path-based) are, however, considered experimental.
Bulk actions (midPoint scripts) work in so called pipes and filters model, just like e.g. traditional UNIX shell scripts. They consist of a number of primitive activities chained together into a sequence or sometimes into a more complex structure. Input from each activity is fed into the activity that immediately follows.
However, sometimes it is useful to keep a global context for execution of these activities. It is available in each activity execution. It is split when execution is split, for example when a search is executed and an execution "branch" is created for each object found.
Currently this context contains a set of variables. For the time being, these variables are initialized when the midPoint script starts, and are considered read-only during the execution of the whole script. In the future we might consider allowing additions or modifications into these variables, making the processing much more flexible (at the cost of deviation from pure pipes and filters model).
The main use of the current implementation is easy parameterization of bulk actions: for example if we want to find all users of employeeType X and set their employeeType to Y, values for X and Y can be stored in bulk action variables.
There are the following variables available by default:
|task||TaskType||The current task (transient for synchronous execution or persistent for asynchronous one).||Always.|
|ruleEvaluationContext||PolicyRuleEvaluationContext||Context for policy rule evaluation.||When using bulk action in to evaluate object state constraint.|
It is possible to define additional variables within the
Example 1: Apply some action on user whose name is configurable
<variables> section defines a single variable (userName). Its value is taken from task's extension. It is then used in the search filter.
Example 2: Define variables as constants or expressions
<variables> section we can use not only path expressions but any other suitable ones. However, this feature is considered to be an experimental one.
Note that this sample is artificial one, used for testing this mechanism. We define 5 variables. Some of them are path-based (userName, groups); some are defined as literal values (academicYear, calendarYear) and one is computed by an expression (deadline).
For expression-based variables it is necessary to specify their type. For value-based the type is derived from the literal value xsi:type (if present).
Available since v3.7devel-714-ga4ad63b (October 20th, 2017).
See also Task template HOWTO to see how these feature can be used to execute parameterized bulk actions in ad-hoc tasks, created from a task template.