How to create and register custom type or node


#1

I’m trying to create a custom type which extends the serviceTask. Based on that, the elementTemplate will be appliedTo custom node.

I’ve referred camunda.json from camunda-bpmn-moddle example to implement the same. The implementation as follow.

Modeler extension with custom moddleExtension:

this.modeler = new RtBpmnModeler({
      container: '#js-canvas',
      moddleExtensions: {
              // registration
              camunda: camundaModdleDescriptor, // <-- imported resources/camunda.json from camunda-bpmn-moddle example. 
       }
    });

The JSON is having a type as ServiceTaskLike which extends bpmn:ServiceTask. The code snippet from camunda.json file below.

  {
      "name": "ServiceTaskLike",
      "extends": [
        "bpmn:ServiceTask",
        "bpmn:BusinessRuleTask",
      ],
      "properties": [
        {
          "name": "expression",
          "isAttr": true,
          "type": "String"
        },
       ...
      ]
}

I’ve tried to load (drag and drop the custom element to canvas) the types as <ServiceTaskLike> & <bpmn:ServiceTaskLike> both failed to load the task and throws the below issue.

image

Is this the correct way to register and usage of custom type?


#2

Have a look at this example for hints.

Your implementation should look similar.