Spring Boot + Camunda BPMN Script Task Example

Video
This tutorial is explained in the below Youtube Video.A script task in Camunda is a type of task in a business process model that allows you to execute a piece of code or script directly within the process flow. It's a way to add custom logic or perform specific operations without needing to create a separate Java class or service. Script tasks can be written in various scripting languages supported by Camunda, such as JavaScript, Groovy, or Python. They are useful for simple operations like data manipulation, calculations, or making decisions based on process variables. When the process reaches a script task, it executes the script and then moves on to the next task. You can use script tasks to:Spring Boot Camunda Tutorials
Spring Boot + Camunda Hello World Example. Spring Boot + Camunda Script Task Example. Spring Boot + Camunda Service Task Example. Spring Boot + Camunda Service Task - Delegate Expression Example. Spring Boot + Camunda Service Task - Expression Example.
- Modify process variables
- Perform calculations
- Make decisions based on conditions
- Interact with external systems
- Log information
Implementation
Download the source code we had implemented in Spring Boot 3 + Camunda BPMN hello world example tutorial. So previous we had created a bpmn diagram as follows-
Also the script task it made use of inline javascript. Here the script task it printed some text to the console.

Next instead of inline script we will make use of external script. For this in resource folder create a new javascript file named test.js as follows -
print("Hello JavaInUse");Then in the bpmn diagram select the script task -> In script type select External Resource -> Name the resource as test.js.

Start the spring boot application and then go to the url - http://localhost:8080/executetask. If we now run the program we get the output as follows.

