Connect modeler elements programmatically

Hello Camunda Team,
Is there a way to connect the task elements thru code without using the sequence /message flow action from the palette
I need only to connect bpmn:sequenceFlow elements in the bpmn xml without a visual connection (arrow shapes should be not be visible )

Any help is appreciated.

Kind regards,

you can create your BPMN with the Model API: https://docs.camunda.org/manual/7.5/user-guide/model-api/bpmn-model-api/

Is that the sort of thing you want to do?

Hey Stephen,
thank you for the quick response,

Check below my test case:
In the bpmn xml example In Progress and Approved are connected with the bpmn:sequenceFlow attributes:

  1. The attached Bpmn xml contains explicit connection between In Progress and Approved tasks below is the rendering in the diagram:

  2. The expected rendering in the diagram Bpmn xml will contain an implicit connection between In Progress and Approved tasks:

    <?xml version="1.0" encoding="UTF-8"?>
    <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
      <bpmn:process id="Process_1" isExecutable="false">
        <bpmn:startEvent id="StartEvent_1" name="Start">
          <bpmn:outgoing>SequenceFlow_0hft36n</bpmn:outgoing>
        </bpmn:startEvent>
        <bpmn:task id="Task_18d2r4l" name="In Progress">
          <bpmn:incoming>SequenceFlow_0hft36n</bpmn:incoming>
          <bpmn:incoming>SequenceFlow_03ifuok</bpmn:incoming>
          <bpmn:outgoing>SequenceFlow_1jtudln</bpmn:outgoing>
          <bpmn:outgoing>SequenceFlow_0tddfhk</bpmn:outgoing>
        </bpmn:task>
        <bpmn:sequenceFlow id="SequenceFlow_0hft36n" sourceRef="StartEvent_1" targetRef="Task_18d2r4l" />
        <bpmn:endEvent id="EndEvent_0zyl0iw" name="End">
          <bpmn:incoming>SequenceFlow_1jtudln</bpmn:incoming>
          <bpmn:incoming>SequenceFlow_0zw5ha9</bpmn:incoming>
        </bpmn:endEvent>
        <bpmn:sequenceFlow id="SequenceFlow_1jtudln" sourceRef="Task_18d2r4l" targetRef="EndEvent_0zyl0iw" />
        <bpmn:task id="Task_10qizfe" name="Approved">
          <bpmn:incoming>SequenceFlow_0tddfhk</bpmn:incoming>
          <bpmn:outgoing>SequenceFlow_0zw5ha9</bpmn:outgoing>
          <bpmn:outgoing>SequenceFlow_03ifuok</bpmn:outgoing>
        </bpmn:task>
        <bpmn:sequenceFlow id="SequenceFlow_0tddfhk" sourceRef="Task_18d2r4l" targetRef="Task_10qizfe" />
        <bpmn:sequenceFlow id="SequenceFlow_0zw5ha9" sourceRef="Task_10qizfe" targetRef="EndEvent_0zyl0iw" />
        <bpmn:sequenceFlow id="SequenceFlow_03ifuok" sourceRef="Task_10qizfe" targetRef="Task_18d2r4l" />
      </bpmn:process>
      <bpmndi:BPMNDiagram id="BPMNDiagram_1">
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
          <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
            <dc:Bounds x="173" y="102" width="36" height="36" />
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape id="Task_18d2r4l_di" bpmnElement="Task_18d2r4l">
            <dc:Bounds x="283" y="80" width="100" height="80" />
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge id="SequenceFlow_0hft36n_di" bpmnElement="SequenceFlow_0hft36n">
            <di:waypoint xsi:type="dc:Point" x="209" y="120" />
            <di:waypoint xsi:type="dc:Point" x="283" y="120" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="201" y="110" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNShape id="EndEvent_0zyl0iw_di" bpmnElement="EndEvent_0zyl0iw">
            <dc:Bounds x="569" y="102" width="36" height="36" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="542" y="138" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge id="SequenceFlow_1jtudln_di" bpmnElement="SequenceFlow_1jtudln">
            <di:waypoint xsi:type="dc:Point" x="383" y="120" />
            <di:waypoint xsi:type="dc:Point" x="569" y="120" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="431" y="110" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNShape id="Task_10qizfe_di" bpmnElement="Task_10qizfe">
            <dc:Bounds x="282" y="203" width="100" height="80" />
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge id="SequenceFlow_0zw5ha9_di" bpmnElement="SequenceFlow_0zw5ha9">
            <di:waypoint xsi:type="dc:Point" x="382" y="243" />
            <di:waypoint xsi:type="dc:Point" x="476" y="243" />
            <di:waypoint xsi:type="dc:Point" x="575" y="133" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="431" y="168" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
      </bpmndi:BPMNDiagram>
    </bpmn:definitions>

Thank you again.Explicit connection.bpmn (4.5 KB)

Can you explain a bit more of your use case? Are you looking to build a State Machine?

These processes come to mind:

Hey,
I’m just looking how to connect task via javascript code without the arrow connection shapes:
In my case i have a generic task that will be dropped in the diagram then all other tasks will connect to it implictly without
using the sequence/Message fow action,
i would like to produce a bpmn xml files which contains a generic task which has connection to all other tasks
but the rendring in the diagram will hide this connection.

regards,

Hi,

maybe your use case is covered by CMMN? You can start here for further reading: https://docs.camunda.org/get-started/cmmn11/

Cheers, Ingo

2 Likes

@dhaker_gouissem if you are only looking to make a visual change but leave the xml the same, I would ask on: https://forum.bpmn.io, and see what options they give you to extend/modify bpmn-js

1 Like

Hi @dhaker_gouissem,

is it only important for you to have DI part customized, or execution should be affected too?
It sounds to me like you are trying to do something conceptually really out of scope of bpmn. I think you should take a look at CMMN, as Ingo mentioned, with call activity integration in your process.

Cheers,
Askar.

1 Like

Hello,
I’m still digging for a solution, I will check the CMMN project.
just a question is there a way to include a custom attribut called RankOrder = “1” in the bpmn:task attributes which will be set programmatically,

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1" name="Open">
      <bpmn:outgoing>SequenceFlow_1bc95bk</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:task id="Task_0ne4plj" name="In Progress"   RankOrder = "1">
      <bpmn:incoming>SequenceFlow_1bc95bk</bpmn:incoming>
      <bpmn:incoming>SequenceFlow_0ueolp0</bpmn:incoming>
      <bpmn:incoming>SequenceFlow_1bs32ij</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1r4mdx2</bpmn:outgoing>
      <bpmn:outgoing>SequenceFlow_0navib1</bpmn:outgoing>
      </bpmn:task>  <bpmn:task id="Task_17yscmr" name="Approved" RankOrder = "2">
      <bpmn:incoming>SequenceFlow_084pksv</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0ol0tj0</bpmn:outgoing>
</bpmn:task>

kind regards,

@dhaker_gouissem,

at the moment you cannot add attributes out of the box. You would have to extend

and couple of other projects to allow that.

Cheers,
Askar.