How to restrict the scope of a signal to a subset of process instances?


I’m trying to do the following:
I’ve created a process model A, that at some point will trigger twice the execution of a second process B.

Suppose I trigger 2 instances of process A (A1, A2), thus creating 4 instances of process B (B1, B2 triggerred by A1 / B3, B4 triggered by A2).

My goal is to be able to cancel B1 and B2 via a signal thrown from A1.
I am able to create a variable myProcessInstanceId = execution.getProcessInstanceId() in process A, and to pass it into the instances of B, so I have a unique way to connect/match A1 with B1 and B2.

I have tried to define the signal as such
<signal id="DeleteSignal" name="${myProcessInstanceId}" flowable:scope="global"></signal>

But such signal cancels all 4 instances of B, instead of just B1 and B2.

I assume I should use the process instance id variable in the signal id instead, eg.:
<signal id="${myProcessInstanceId}" name="DeleteSignal" flowable:scope="global"></signal>
but this causes app deployment error.

Any idea how I could handle this?

Thanks a lot,

You need to use a signal Expression:

<signalEventDefinition flowable:signalExpression="${throwSignal}"></signalEventDefinition>

to allow for dynamic signals.

All clear, thanks a lot!