Camunda Team Blog

Element Templates in the Camunda Modeler

Written by Nico Rehwaldt on , under Modeling category.

Element templates for BPMN diagrams is one of the exciting features shipped with the latest release of our Camunda Modeler. They allow developers to extend the modeler with custom controls for certain BPMN elements.

A template, once selected for a diagram element, provides custom fields with domain specific validation of user input.

Camunda Modeler Element Templates Screenshot

Element Templates are here

Element Templates in a Nutshell

In essence, element templates define custom inputs, custom validation and a technical mapping for the entered data into the Camunda world.

Once selected from the properties panel they are offered to the user as Custom Fields. Custom fields can be dropdowns, check boxes, input and text areas. On input, the modeler applies domain specific validation and maps the input data to BPMN 2.0 XML and the world of the process engine.

Element Templates in Code

Element templates are read from JSON files situated in resources/element-templates relative to the modelers installation directory.

The example MailTask shown in the screenshot above may be defined like that:

[
  {
    "name": "Mail Task",
    "id": "com.camunda.example.MailTask",
    "appliesTo": [
      "bpmn:ServiceTask"
    ],
    "properties": [
      {
        "label": "Implementation Type",
        "type": "String",
        "value": "com.mycompany.MailTaskImpl",
        "editable": false,
        "binding": {
          "type": "property",
          "name": "camunda:javaDelegate"
        }
      },
      ...
      {
        "label": "Template",
        "description": "You can use freemarker templates ${...} here",
        "value": "Hello ${firstName}!",
        "type": "Text",
        "binding": {
          "type": "camunda:inputParameter",
          "name": "messageBody",
          "scriptFormat": "freemarker"
        },
        "constraints": {
          "notEmpty": true
        }
      },
      {
        "label": "Result Status",
        "description": "Process variable to assign the send result to",
        "type": "String",
        "value": "mailSendResult",
        "binding": {
          "type": "camunda:outputParameter",
          "source": "${ resultStatus }"
        }
      },
      {
        "label": "Send Async?",
        "type": "Boolean",
        "value": true,
        "binding": {
          "type": "property",
          "name": "camunda:asyncBefore"
        }
      }
    ]
  }
]

The actual details on the template definition go beyond a simple blog post. Consider checking out our in-depth element templates documentation or any of the other resources listed below.

More on Element Templates

Would you like to try out element templates? These resources help you to learn more:

Feedback Wanted

Element templates add powerful options to extend the Camunda Modeler with pre-defined user, service tasks as well as other BPMN elements.

Do you find these extensions useful? Is there anything you are missing? We are happy to hear your feedback in the Camunda Modeler forum.