Hello ${name}! – Templating with camunda BPM

By
  • Blog
  • >
  • Hello ${name}! – Templating with camunda BPM
TOPICS

30 Day Free Trial

Bring together legacy systems, RPA bots, microservices and more with Camunda

Sign Up for Camunda Content

Get the latest on Camunda features, events, top trends, and more.

TRENDING CONTENT
As part of our scripting improvements we also addressed templating as a new feature of camunda BPM. With the new camunda BPM 7.2.0-alpha3 release it is now also possible to use FreeMarker or Apache Velocity templates inside your BPMN process.


We integrated this template engines as JSR 223 compatible scripting engines. Therefore we create small wrappers for these template engines in our camunda-template-engines-jsr223 project. This has the advantage that we do not need new extension elements or attributes for the BPMN xml. Instead a template can be used everywhere a script can be used. This is especially useful for script tasks and input output mappings. If the template engine JSR 223 wrapper is part of your classpath you can use the name of the template engine as script language.

The maven coordinates of the template engine wrappers a the following if you want to use them with an embedded engine or in a JUnit test case:

<dependency>
  <groupId>org.camunda.template-engines</groupId>
  <artifactId>camunda-template-engines-freemarker</artifactId>
  <version>1.0.0</version>
</dependency>

<dependency>
  <groupId>org.camunda.template-engines</groupId>
  <artifactId>camunda-template-engines-velocity</artifactId>
  <version>1.0.0</version>
</dependency>

<code>

The following example shows a simple use case where an input output mapping is used on a service task to generate a text content needed by this task. Here we use the FreeMarker template engine to generate the body of an email.

<code>

<code>As you can see the process variables in the current scope can directly be used in the template. The result of the processed template is than save in a local variable which is available inside of the service task.

<code>Another interesting use case for templates are camunda connectors (added in 7.2.0-alpha2). As templates like scripts can be loaded from external resources it is possible to use the a SOAP envelope template in multiple processes or projects. An example for such an template can be found in our SOAP connector example.

<code>

<code>As a side effect of this new feature we have demonstrated that you can now easily integrate own scripting-like languages in camunda BPM. If it is possible to create a JSR 223 compatible wrapper it can be used in camunda BPM.

<code>To read more technical details about templating please visit our user guide. And please let us know what you think about this new feature.


Try All Features of Camunda

Related Content

See how Funding Societies is taking advantage of process orchestration to automate their lending process, greatly improving outcomes for their customers.
Process blueprints can now be found on Camunda marketplace! Read on to learn how they can help you and how you can contribute.
Achieve operational superiority with the intelligent backbone of service orchestration. Learn how and why you should orchestrate your services.