Using setVariable with activityId

Let’s say we have a process model like so:

When Task is executed, we have three activity instances organized in a hierarchy:

Process Instance 10 (instance of Process Definition)
                  ^
                  |
Subprocess Instance 11 (instance of Subprocess)
                  ^
                  |
Task Instance 12 (instance of Task)

Assume we call setVariable("key", "value", "Subprocess") API in the context of task instance 12. Then the API traverses the path from instance 12 upwards to the root until it finds an instance of Subprocess and sets the variable there. That’s what I mean with next higher instance. It stops searching once it finds the first such instance, because there cannot be another instance of Subprocess in that path. Of course, the overall tree can have multiple instances of Subprocess, but each path from a leaf to the root can contain at most one such instance.

3 Likes