Camunda 8 multi-instance completing condition expression

Hello, I’m trying to work with a multi-instance in C8 and as for now everything works good but not really the way I want it to.

The thing is, as you can see in the picture above, I added the Input/Ouput collection/element and a completing condition of course, which is my question about !
I want the happy path to be executed as long as all elements of my list are “true”.
And since I only have 3 elements in my list (for now) this condition is not that bad, but what if I got a 100 for example ? Of course I wouldn’t put the condition this way then !

I tried the FEEL List expression (every x in results satisfies x = true), but for some reason this one doesn’t work !

So, I just wanna know if there’s an alternatif solution, or if the FEEL expression I used is wrong ?

Thank you in advance !

Hi @Hanane-Boutzrout :wave:

The completion condition allows you to complete the multi-instance before all instances of the multi-instance have been completed.

However, in your example it seems you want to define what should happen after all the instances of the multi-instance have been completed, because you want to react to the result that each produced. Only if all results are true, do you want to take a specific path. Otherwise, you’d like to take a different path. So it seems you don’t want to complete the multi-instance pre-maturely.

I think you should not use the completion condition. Instead, use an exclusive gateway after the multi-instance to control the different flows.

PS: I don’t know why the every x in results satisfies x = true doesn’t work. IMO it should work. Perhaps this is a bug.

Hello @korthout, Thans for your reply

And thank you for this explanation, I didn’t know that was its role !

And actually, I did try the exclusive gateway,

But still, this expression did not work with it as well !!

That’s strange. It works for me.

Can you share your process model with the exclusive gateway? And on what version are you seeing this behavior?

My Process

Make sure to start an instance with a variable like {"results":[true, true, true]}, and notice which path is taken.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="definitions_62d6811b-c3ce-44f5-820a-3cffd4ff06fe" targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
  <process id="process" isExecutable="true">
    <startEvent id="startEvent_9729c38e-99ea-4481-aaa2-61817b7c378f">
      <outgoing>sequenceFlow_e90891c1-82dc-4f92-868f-8eac88dfc4ec</outgoing>
    </startEvent>
    <exclusiveGateway default="s2" id="exclusiveGateway_131898ec-82eb-4860-9bc2-afb73fc89f2a">
      <incoming>sequenceFlow_e90891c1-82dc-4f92-868f-8eac88dfc4ec</incoming>
      <outgoing>s1</outgoing>
      <outgoing>s2</outgoing>
    </exclusiveGateway>
    <sequenceFlow id="sequenceFlow_e90891c1-82dc-4f92-868f-8eac88dfc4ec" sourceRef="startEvent_9729c38e-99ea-4481-aaa2-61817b7c378f" targetRef="exclusiveGateway_131898ec-82eb-4860-9bc2-afb73fc89f2a"/>
    <sequenceFlow id="s1" sourceRef="exclusiveGateway_131898ec-82eb-4860-9bc2-afb73fc89f2a" targetRef="end1">
      <conditionExpression id="conditionExpression_edc9cc38-4e98-4867-9bab-42b6c387ecd0">=every x in results satisfies x = true</conditionExpression>
    </sequenceFlow>
    <endEvent id="end1" name="end1">
      <incoming>s1</incoming>
    </endEvent>
    <sequenceFlow id="s2" sourceRef="exclusiveGateway_131898ec-82eb-4860-9bc2-afb73fc89f2a" targetRef="end2"/>
    <endEvent id="end2" name="end2">
      <incoming>s2</incoming>
    </endEvent>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_d812b0b9-b215-459e-b267-120309f7c27b">
    <bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_3ad8a8fc-06b0-4521-959b-36d4c3ef86e0">
      <bpmndi:BPMNShape bpmnElement="startEvent_9729c38e-99ea-4481-aaa2-61817b7c378f" id="BPMNShape_25d0409c-f3e3-4a08-8f7f-1c628ab9f875">
        <dc:Bounds height="36.0" width="36.0" x="100.0" y="100.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusiveGateway_131898ec-82eb-4860-9bc2-afb73fc89f2a" id="BPMNShape_ae5c2709-0476-4a0a-b401-dc0c0b6a5aee" isMarkerVisible="true">
        <dc:Bounds height="50.0" width="50.0" x="186.0" y="93.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_e90891c1-82dc-4f92-868f-8eac88dfc4ec" id="BPMNEdge_aa35b3fc-5342-4707-8296-488e7bf54966">
        <di:waypoint x="136.0" y="118.0"/>
        <di:waypoint x="186.0" y="118.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape bpmnElement="end1" id="BPMNShape_72bd2d7d-eb44-47b5-8317-4a74bddd610c">
        <dc:Bounds height="36.0" width="36.0" x="286.0" y="100.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="s1" id="BPMNEdge_45740e14-ef89-426f-b01b-152f7938c37d">
        <di:waypoint x="236.0" y="118.0"/>
        <di:waypoint x="286.0" y="118.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape bpmnElement="end2" id="BPMNShape_9ef3d8fa-590d-4d4e-8524-c2e79e032e98">
        <dc:Bounds height="36.0" width="36.0" x="286.0" y="186.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="s2" id="BPMNEdge_47b65246-0977-4850-a97c-084204899d39">
        <di:waypoint x="211.0" y="143.0"/>
        <di:waypoint x="211.0" y="204.0"/>
        <di:waypoint x="286.0" y="204.0"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>