# Flowable UI Subprocess

**URL:** <https://forum.flowable.org/t/flowable-ui-subprocess/5213>\
**Category:** Flowable Engine\
**Created:** [January 12, 2020, 11:28am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213 "2020-01-12T11:28:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 12, 2020, 11:28am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/1 "2020-01-12T11:28:10Z")

</div>

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](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/3a58d7dd00b01140bb92a7eae5e12959357d84c9.png)

---

<div class="post-metadata">

**Author:** ![PHH](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/phh/32/94_2.png) [@PHH](https://forum.flowable.org/u/PHH)\
**Post date:** [January 13, 2020, 8:29am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/2 "2020-01-13T08:29:38Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 13, 2020, 9:55am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/3 "2020-01-13T09:55:58Z")

</div>

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](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/1/1ea147939559acb4791a06c685020ec0355433df.png)

This is right?

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 13, 2020, 4:11pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/4 "2020-01-13T16:11:25Z")

</div>

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>
```

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 14, 2020, 1:56pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/5 "2020-01-14T13:56:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [January 17, 2020, 3:47pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/6 "2020-01-17T15:47:17Z")

</div>

> [@elc](#):
>
> There is still a problem. When the allForwarderGroupIds variable is updated, I want to restart the subprocess

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?

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 19, 2020, 11:48am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/7 "2020-01-19T11:48:13Z")

</div>

That is what I did:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/315586920a44f00b92466e9b6d9e35331d7a6315.png)

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 ?

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 19, 2020, 2:38pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/8 "2020-01-19T14:38:11Z")

</div>

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:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/e/e4c547184c84d77aed65c0451decb378a8425efa.png)

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:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/5/5204e8a19b4109ac31b4ea05af489d26172a9761.png)

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 19, 2020, 3:14pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/10 "2020-01-19T15:14:54Z")

</div>

I am trying this. Thanks a lot…

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 19, 2020, 4:09pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/11 "2020-01-19T16:09:08Z")

</div>

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.  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/307cf67a213e30a2d0d77e8fedaf6652c2dd35e2.png)  
Notify Booking List Process:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/3/3785a719bcb8bd031db396c99347677f2be5d3eb.png)  
Notify Additional Booking Process:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/f/f9964b6168aa5677cd51ed3b04812999fc90ac7d.png)

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 11:49am UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/12 "2020-01-20T11:49:25Z")

</div>

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.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/e/ef01aa9caf4ef4fee0f0d0b01e07353812750d59.png)

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 1:11pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/13 "2020-01-20T13:11:21Z")

</div>

It seems because it is a loop on the same signal

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 20, 2020, 2:47pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/14 "2020-01-20T14:47:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 3:00pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/15 "2020-01-20T15:00:47Z")

</div>

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

What it’s mean?

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 20, 2020, 3:05pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/16 "2020-01-20T15:05:49Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/9/94ca5f8d93d02ab8a788de35300fbc8988b17c81.png)

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

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/d/d4f7b3cfb581cefd244ab3d83ecc32be8db5c897.png)

> **[BPMN 2.0 Constructs · Flowable Open Source Documentation](https://flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#inclusive-gateway)**
>
> This chapter covers the BPMN 20 constructs supported by Flowable, as well as custom extensions to the BPMN standard.

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 3:30pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/17 "2020-01-20T15:30:31Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/0/0ec1e033351a61b9c26f61e73a0de97c17298baf.png)

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.

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 20, 2020, 3:49pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/18 "2020-01-20T15:49:01Z")

</div>

It’s waiting on the subprocess to complete:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/9/920a7801d55e0dfb8fd531b7537d95adaf47a9c1.png)

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.

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 3:51pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/19 "2020-01-20T15:51:39Z")

</div>

> [@wwitt](#):
>
> 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](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/7/7de560641f67250f4d5a86c07a6233c6b1fc61a3.png)

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

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [January 20, 2020, 4:02pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/20 "2020-01-20T16:02:01Z")

</div>

Something like this should do it.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/0/067b989f90d776a93b635990353b738945e96b81.png)

---

<div class="post-metadata">

**Author:** ![elc](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elc](https://forum.flowable.org/u/elc)\
**Post date:** [January 20, 2020, 4:14pm UTC](https://forum.flowable.org/t/flowable-ui-subprocess/5213/21 "2020-01-20T16:14:17Z")

</div>

This works!!! 😃 🍾 🍾 🍾  
Thanks a lot William!!!
