Flowable UI Subprocess

Hi,
I have a process model which contains a subprocess which contains 2 user tasks.
When I create an instance of the process, I give it a variable userNames which contains a list of string (‘userA’, ‘userB’, ‘userC’)

All the tasks in the subprocess contains a variable userName.
I want to reproduce the subprocess for all entities of the variable UserNames.

Also, I want to be available to update the variable UserNames by adding userD, and the subprocess will reproduce also for the new entity userD.
Somebody can help me? Thanks a lot

image

Hi,

It sounds like you need to use a multi-instance subprocess (any activity can be multi-instance):
https://flowable.org/docs/userguide/index.html#bpmnMultiInstance

You’d use the list of users as the collection passed to the MI subprocess, and the subprocess would be executed for each user. The choice is also if the multiple executions should be done in parallel or sequentially.

Cheers,
Paul.

Thanks for your reply.
That is what I did.
Right now, I am looking for the solution to loop on my list.

This is my xml for the subprocess:

    <subProcess id="sid-8367199A-7E93-41AE-98E4-9338759291C8" name="Quote manager">
  <userTask id="task_booking_note" name="booking notification" flowable:candidateGroups="forwarderGroupId" flowable:category="shipment" flowable:formFieldValidation="true">
    <multiInstanceLoopCharacteristics isSequential="true" flowable:collection="${allForwarderGroupIds}" flowable:elementVariable="forwarderGroupId" >
    </multiInstanceLoopCharacteristics>
  </userTask>
  <userTask id="task_booking_option" name="submit booking option" flowable:candidateGroups="forwarderGroupId" flowable:category="shipment" flowable:formFieldValidation="true">
    <multiInstanceLoopCharacteristics isSequential="true" flowable:collection="${allForwarderGroupIds}" flowable:elementVariable="forwarderGroupId" >
    </multiInstanceLoopCharacteristics>
  </userTask>
  <startEvent id="sid-162CDDC0-0F42-4C70-B34B-CE4C8548CA2B" flowable:formFieldValidation="true"></startEvent>
  <endEvent id="sid-7A8FA354-8310-4A5E-8FF8-A13359EDF14F"></endEvent>
  <sequenceFlow id="sid-5D46BAE0-8ECF-4564-8861-7A6644833350" sourceRef="task_booking_note" targetRef="task_booking_option"></sequenceFlow>
  <sequenceFlow id="sid-618C716C-A700-4F51-A028-8F72A4D6CBF4" sourceRef="sid-162CDDC0-0F42-4C70-B34B-CE4C8548CA2B" targetRef="task_booking_note"></sequenceFlow>
  <sequenceFlow id="sid-096E55E0-F06A-4732-ABD5-C5F68500F8CB" sourceRef="task_booking_option" targetRef="sid-7A8FA354-8310-4A5E-8FF8-A13359EDF14F"></sequenceFlow>
</subProcess>

image

This is right?

I found a solution. Thanks to PHH.

      <userTask id="task_booking_note" name="booking notification" flowable:candidateGroups="${forwarderGroupId.group_name}" flowable:category="shipment" flowable:formFieldValidation="true">
    <multiInstanceLoopCharacteristics isSequential="true"
      flowable:collection="${allForwarderGroupIds}" flowable:elementVariable="forwarderGroupId" >
    </multiInstanceLoopCharacteristics>
  </userTask>

  <userTask id="task_booking_option" name="submit booking option" flowable:candidateGroups="${forwarderGroupId.group_name}" flowable:category="shipment" flowable:formFieldValidation="true">
    <multiInstanceLoopCharacteristics isSequential="true"
      flowable:collection="${allForwarderGroupIds}" flowable:elementVariable="forwarderGroupId" >
    </multiInstanceLoopCharacteristics>
  </userTask>

There is still a problem. When the allForwarderGroupIds variable is updated, I want to restart the subprocess on the same time that the first task is already running.

How do you detect these changes to the list? Are these updated external to Flowable?
If so, what about adding a signal boundary event to the subprocess and throwing the signal through the runtimeService#signalEventReceived, that then interrupts anything inside the subprocess and restarts it?

That is what I did:

When I want to create a new list of task for new the forwarder created, I execute the signal and it launch the second subprocess (localhost:8080/flowable-task/process-api/runtime/executions/{executionId})
But, I want to be able to execute the signal many times. And I note that it is impossible.
There is a solution to be able to execute the subprocess via API many times ?

It seems like what you are trying to do is:

  • Start a process with a supplied list of bookings
  • For every item on a supplied list:
    • Execute “Booking Notification”
    • Execute “Submit Booking Option”
  • At the same time wait for a signal, when it arrives:
    • Execute “Booking Notification”
    • Execute “Submit Booking Option”

The issue with your process is that is does not know to wait for the signal again. You’d need to loop the process flow back around to the intermediate signal catching event. The issue with that set up is that the process would never know when it is done. You’d end up with something more like this:

This has the limitation that only one additional booking can be in flight at a time. If you want multiple additional bookings in flight at the same time, you end up with something like this:

1 Like

I am trying this. Thanks a lot…

If you are open to doing some of your modeling in CMMN, there is a cleaner way of modeling this kind of interaction.

In this bit of CMMN:

  • Completion of the “Collect Initial List Of Bookings” task activates the “Booking Notification Stage”
  • As soon as the stage activates, the “Notify Booking List” Process Task executes.
    • This starts a BPMN process to handle the initial list.
  • Also in the stage, there is a manually activated, repeatable, process task called “Notify Additional Booking”
    • When the task is activated, it begins a BPMN process to Notify Additional Booking items
  • Since the stage is not auto-terminating it remains active until it is manually ended. You could also use an exit sentry so that some other event in the case closes the stage.

    Notify Booking List Process:

    Notify Additional Booking Process:

Thanks, but right now I prefer the use the bpmn model. The first model is what I want to use.
But I have a problem. The second parallel gateway don’t continue to the “Add booking” signal. So I can’t access it. I don’t understand where is the problem.

It seems because it is a loop on the same signal

There does seem to be an issue with using two parallel gateways back to back like this. Switching the second gateway to an inclusive gateway seems to make it work.

Switching the second gateway to an inclusive gateway seems to make it work.

What it’s mean?

Technically speaking with would also work without the second gateway, but I find using gateways to join process flows to be more readable:

I can call the signal only one time. After, I can’t use it. I mean the array which connect the subprocess to the inclusive gateway is not usable.

It’s waiting on the subprocess to complete:

Once you complete the subprocess, the flow will go back through the inclusive gateway and hit the intermediate catching event again. If you want it to be triggerable before the subprocess completes, you’ll need to fork the execution before your subprocess and direct a sequence flow back to the inclusive gateway from there.

Do you know how can I be able to continue the first process, and on the same time can be able to begin a new one?

image

This arrow seems to do this thing but it is not works

Something like this should do it.

1 Like

This works!!! :smiley: :champagne: :champagne: :champagne:
Thanks a lot William!!!